Commit b7212600 authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Jiri Kosina

HID: lenovo: Remove sysfs group on failure path

There is no sysfs_group_remove() on failure path in lenovo_probe_tpkbd().

Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 323ddaa8
...@@ -599,7 +599,8 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) ...@@ -599,7 +599,8 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
GFP_KERNEL); GFP_KERNEL);
if (data_pointer == NULL) { if (data_pointer == NULL) {
hid_err(hdev, "Could not allocate memory for driver data\n"); hid_err(hdev, "Could not allocate memory for driver data\n");
return -ENOMEM; ret = -ENOMEM;
goto err;
} }
// set same default values as windows driver // set same default values as windows driver
...@@ -610,7 +611,8 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) ...@@ -610,7 +611,8 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL); name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
if (name_mute == NULL || name_micmute == NULL) { if (name_mute == NULL || name_micmute == NULL) {
hid_err(hdev, "Could not allocate memory for led data\n"); hid_err(hdev, "Could not allocate memory for led data\n");
return -ENOMEM; ret = -ENOMEM;
goto err;
} }
snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(dev)); snprintf(name_mute, name_sz, "%s:amber:mute", dev_name(dev));
snprintf(name_micmute, name_sz, "%s:amber:micmute", dev_name(dev)); snprintf(name_micmute, name_sz, "%s:amber:micmute", dev_name(dev));
...@@ -634,6 +636,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev) ...@@ -634,6 +636,9 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
lenovo_features_set_tpkbd(hdev); lenovo_features_set_tpkbd(hdev);
return 0; return 0;
err:
sysfs_remove_group(&hdev->dev.kobj, &lenovo_attr_group_tpkbd);
return ret;
} }
static int lenovo_probe_cptkbd(struct hid_device *hdev) static int lenovo_probe_cptkbd(struct hid_device *hdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment