diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-12 20:08:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-12 20:08:49 -0400 |
commit | 645a992934c8007fa17ac2e512ce73c100ed1614 (patch) | |
tree | ecca109b6651034faf382d253885b09ec53138d3 | |
parent | b2cc9c19e48bcf00f10c23fbf9f6abe43f6929d5 (diff) | |
parent | 5939212df87e9377dd3813904264b94a962d19ca (diff) |
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
-rw-r--r-- | drivers/hid/hid-multitouch.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index dc3ae5c56f56..d39a5cede0b0 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -264,9 +264,12 @@ static struct mt_class mt_classes[] = { | |||
264 | static void mt_free_input_name(struct hid_input *hi) | 264 | static void mt_free_input_name(struct hid_input *hi) |
265 | { | 265 | { |
266 | struct hid_device *hdev = hi->report->device; | 266 | struct hid_device *hdev = hi->report->device; |
267 | const char *name = hi->input->name; | ||
267 | 268 | ||
268 | if (hi->input->name != hdev->name) | 269 | if (name != hdev->name) { |
269 | kfree(hi->input->name); | 270 | hi->input->name = hdev->name; |
271 | kfree(name); | ||
272 | } | ||
270 | } | 273 | } |
271 | 274 | ||
272 | static ssize_t mt_show_quirks(struct device *dev, | 275 | static ssize_t mt_show_quirks(struct device *dev, |
@@ -1040,11 +1043,11 @@ static void mt_remove(struct hid_device *hdev) | |||
1040 | struct hid_input *hi; | 1043 | struct hid_input *hi; |
1041 | 1044 | ||
1042 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); | 1045 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); |
1043 | hid_hw_stop(hdev); | ||
1044 | |||
1045 | list_for_each_entry(hi, &hdev->inputs, list) | 1046 | list_for_each_entry(hi, &hdev->inputs, list) |
1046 | mt_free_input_name(hi); | 1047 | mt_free_input_name(hi); |
1047 | 1048 | ||
1049 | hid_hw_stop(hdev); | ||
1050 | |||
1048 | kfree(td); | 1051 | kfree(td); |
1049 | hid_set_drvdata(hdev, NULL); | 1052 | hid_set_drvdata(hdev, NULL); |
1050 | } | 1053 | } |