Skip to content

Commit 645a992

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull input layer bugfix from Jiri Kosina: "Memory leak regression fix from Benjamin Tissoires" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: HID: multitouch: prevent memleak with the allocated name
2 parents b2cc9c1 + 5939212 commit 645a992

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/hid/hid-multitouch.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,12 @@ static struct mt_class mt_classes[] = {
264264
static void mt_free_input_name(struct hid_input *hi)
265265
{
266266
struct hid_device *hdev = hi->report->device;
267+
const char *name = hi->input->name;
267268

268-
if (hi->input->name != hdev->name)
269-
kfree(hi->input->name);
269+
if (name != hdev->name) {
270+
hi->input->name = hdev->name;
271+
kfree(name);
272+
}
270273
}
271274

272275
static ssize_t mt_show_quirks(struct device *dev,
@@ -1040,11 +1043,11 @@ static void mt_remove(struct hid_device *hdev)
10401043
struct hid_input *hi;
10411044

10421045
sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
1043-
hid_hw_stop(hdev);
1044-
10451046
list_for_each_entry(hi, &hdev->inputs, list)
10461047
mt_free_input_name(hi);
10471048

1049+
hid_hw_stop(hdev);
1050+
10481051
kfree(td);
10491052
hid_set_drvdata(hdev, NULL);
10501053
}

0 commit comments

Comments
 (0)