LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fix  slab-out-of-bounds Write in betop_probe
@ 2021-08-16 20:15 F.A.Sulaiman
  2021-08-17  0:05 ` kernel test robot
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: F.A.Sulaiman @ 2021-08-16 20:15 UTC (permalink / raw)
  To: jikos, benjamin.tissoires
  Cc: F.A.Sulaiman, linux-input, linux-kernel, paskripkin

This patch resolves the bug 'KASAN: slab-out-of-bounds Write in betop_probe' reported by Syzbot.
This checkes hid_device's input is non empty before it's been used.

Signed-off-by: F.A. SULAIMAN <asha.16@itfac.mrt.ac.lk>
---
 drivers/hid/hid-betopff.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hid/hid-betopff.c b/drivers/hid/hid-betopff.c
index 467d789f9bc2..27b57aef9a0a 100644
--- a/drivers/hid/hid-betopff.c
+++ b/drivers/hid/hid-betopff.c
@@ -121,8 +121,18 @@ static int betopff_init(struct hid_device *hid)
 
 static int betop_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
+	struct hid_input *hidinput;
+	struct input_dev *dev;
 	int ret;
 
+	if (list_empty(&hdev->inputs)) {
+		hid_err(hdev, "no inputs found\n");
+		return -ENODEV;
+	}
+
+	hidinput = list_first_entry(&hdev->inputs, struct hid_input, list);
+	dev = hidinput->input;
+
 	if (id->driver_data)
 		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-09-15 14:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 20:15 [PATCH] fix slab-out-of-bounds Write in betop_probe F.A.Sulaiman
2021-08-17  0:05 ` kernel test robot
2021-08-17  0:35 ` kernel test robot
2021-08-17 20:58 ` kernel test robot
2021-08-19 18:47 ` Jiri Kosina
2021-08-22 13:43 ` [PATCH v2] HID: betop: " F.A.Sulaiman
2021-08-22 16:01   ` Pavel Skripkin
2021-08-24 15:07 ` [PATCH v3] " F.A.Sulaiman
2021-08-24 15:12   ` Pavel Skripkin
2021-09-15 14:31   ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).