Thread (3 messages) 3 messages, 3 authors, 2022-04-03

[PATCH] HID: hid-ntrig: fix the error handling code in ntrig_probe

STALE1645d

From: Mingxuan Xiang <hidden>
Date: 2022-03-13 15:06:13
Also in: lkml
Subsystem: hid core layer, the rest · Maintainers: Jiri Kosina, Benjamin Tissoires, Linus Torvalds

If sysfs_create_group in ntrig_probe fails, sysfs_remove_group in
ntrig_remove would hit WARN().

Fix this by returning err in ntrig_probe rather than ignoring the
failure of sysfs_create_group.

CC: Dongliang Mu <dzm91@hust.edu.cn>
Fixes: eab32f5f6557 ("HID: ntrig: add sysfs access to filter parameters")
Signed-off-by: Mingxuan Xiang <redacted>
---
 drivers/hid/hid-ntrig.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
index b5d26f03fe6b..f49427815d98 100644
--- a/drivers/hid/hid-ntrig.c
+++ b/drivers/hid/hid-ntrig.c
@@ -951,10 +951,14 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
 	ret = sysfs_create_group(&hdev->dev.kobj,
 			&ntrig_attribute_group);
-	if (ret)
+	if (ret) {
 		hid_err(hdev, "cannot create sysfs group\n");
+		goto err_sysfs_create;
+	}
 
 	return 0;
+err_sysfs_create:
+	hid_hw_stop(hdev);
 err_free:
 	kfree(nd);
 	return ret;
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help