diff options
author | Michal Malý <madcatxster@gmail.com> | 2012-03-31 05:35:05 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-04-02 22:11:12 -0400 |
commit | 6a2e176b2d6ae6bb528c0c1a50a6332e176cda12 (patch) | |
tree | 14799f485bbbf3bc0e32f744b430d0ebb2421088 | |
parent | 8577dbf9d6eb07213caefb49e2017c177c5f023d (diff) |
HID: lg4ff: Remove sysfs iface before deallocating memory
This patch fixes a possible race condition caused by the sysfs
interface being removed after the memory used by the interface
was already kfree'd.
Signed-off-by: Michal Malý <madcatsxter@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/hid-lg.h | 2 | ||||
-rw-r--r-- | drivers/hid/hid-lg4ff.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/hid/hid-lg.h b/drivers/hid/hid-lg.h index 500457b67b21..d64cf8d2751e 100644 --- a/drivers/hid/hid-lg.h +++ b/drivers/hid/hid-lg.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef __HID_LG_H | 1 | #ifndef __HID_LG_H |
2 | #define __HID_LG_H | 2 | #define __HID_LG_H |
3 | 3 | ||
4 | #include <linux/spinlock.h> | ||
5 | |||
6 | struct lg_drv_data { | 4 | struct lg_drv_data { |
7 | unsigned long quirks; | 5 | unsigned long quirks; |
8 | void *device_props; /* Device specific properties */ | 6 | void *device_props; /* Device specific properties */ |
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 6ecc9e220440..11452920a6c3 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c | |||
@@ -466,6 +466,9 @@ int lg4ff_deinit(struct hid_device *hid) | |||
466 | bool found = 0; | 466 | bool found = 0; |
467 | struct lg4ff_device_entry *entry; | 467 | struct lg4ff_device_entry *entry; |
468 | struct list_head *h, *g; | 468 | struct list_head *h, *g; |
469 | |||
470 | device_remove_file(&hid->dev, &dev_attr_range); | ||
471 | |||
469 | list_for_each_safe(h, g, &device_list.list) { | 472 | list_for_each_safe(h, g, &device_list.list) { |
470 | entry = list_entry(h, struct lg4ff_device_entry, list); | 473 | entry = list_entry(h, struct lg4ff_device_entry, list); |
471 | if (strcmp(entry->device_id, (&hid->dev)->kobj.name) == 0) { | 474 | if (strcmp(entry->device_id, (&hid->dev)->kobj.name) == 0) { |
@@ -478,11 +481,10 @@ int lg4ff_deinit(struct hid_device *hid) | |||
478 | } | 481 | } |
479 | 482 | ||
480 | if (!found) { | 483 | if (!found) { |
481 | dbg_hid("Device entry not found!\n"); | 484 | hid_err(hid, "Device entry not found!\n"); |
482 | return -1; | 485 | return -1; |
483 | } | 486 | } |
484 | 487 | ||
485 | device_remove_file(&hid->dev, &dev_attr_range); | ||
486 | dbg_hid("Device successfully unregistered\n"); | 488 | dbg_hid("Device successfully unregistered\n"); |
487 | return 0; | 489 | return 0; |
488 | } | 490 | } |