Skip to contentSkip to conversation

hid:Add missing error checking in mt_probe for creating sysfs_create_group

PATCH Benjamin Tissoires 2 participants 2 messages Feb 3, 2016 1 message not in the archive HID

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 17 lines · Nicholas Krause

This adds the missing error check in the function mt_probe for the call to the function sysfs_create_group for creating the group,mt_attrribute as based on the based input device's device kobject's member as otherwise we assume the sysfs directory is created successfully no matter the return value of sysfs_create_group.

---
 drivers/hid/hid-multitouch.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hid/hid-multitouch.c +0 -0
index 296d499..46ebf06 100644

drivers/hid/hid-multitouch.c static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) · line 1137

Quoted 5 lines
drivers/hid/hid-multitouch.c +2 -0
@@ -1133,6 +1133,8 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 
 	ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
+	if (ret)
+		return ret;

I am not particularly happy with a hard failure here in case the sysfs group doesn't bind. The group is mainly used for debug, and I am not sure anybody but me uses it nowadays.

Could you amend the patch to put a warning in case of a failure but still continue?

Cheers,
Benjamin

Quoted 6 lines
drivers/hid/hid-multitouch.c +0 -0
 	mt_set_maxcontacts(hdev);
 	mt_set_input_mode(hdev);
Signature · 1 line
2.5.0
maintainer
#2 lore raw
Quoted 15 lines · Benjamin Tissoires

drivers/hid/hid-multitouch.c static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) · line 1137

Quoted 10 lines
drivers/hid/hid-multitouch.c +2 -0
index 296d499..46ebf06 100644
@@ -1133,6 +1133,8 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 		return ret;
 
 	ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
+	if (ret)
+		return ret;

I am not particularly happy with a hard failure here in case the sysfs group doesn't bind. The group is mainly used for debug, and I am not sure anybody but me uses it nowadays.

Quoted 2 lines

Could you amend the patch to put a warning in case of a failure but still continue?

Yeah. And also in case of hard failure, some cleanup would have to be done anyway (hid_hw_start() has already happened, etc).

Signature · 2 lines
Jiri Kosina
SUSE Labs