summaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorMichal Malý <madcatxster@gmail.com>2012-03-31 11:35:05 +0200
committerJiri Kosina <jkosina@suse.cz>2012-04-03 04:11:12 +0200
commit6a2e176b2d6ae6bb528c0c1a50a6332e176cda12 (patch)
tree14799f485bbbf3bc0e32f744b430d0ebb2421088 /drivers/hid
parent8577dbf9d6eb07213caefb49e2017c177c5f023d (diff)
downloadlinux-stable-6a2e176b2d6ae6bb528c0c1a50a6332e176cda12.tar.gz
linux-stable-6a2e176b2d6ae6bb528c0c1a50a6332e176cda12.tar.bz2
linux-stable-6a2e176b2d6ae6bb528c0c1a50a6332e176cda12.zip
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>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-lg.h2
-rw-r--r--drivers/hid/hid-lg4ff.c6
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 @@
#ifndef __HID_LG_H
#define __HID_LG_H
-#include <linux/spinlock.h>
-
struct lg_drv_data {
unsigned long quirks;
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)
bool found = 0;
struct lg4ff_device_entry *entry;
struct list_head *h, *g;
+
+ device_remove_file(&hid->dev, &dev_attr_range);
+
list_for_each_safe(h, g, &device_list.list) {
entry = list_entry(h, struct lg4ff_device_entry, list);
if (strcmp(entry->device_id, (&hid->dev)->kobj.name) == 0) {
@@ -478,11 +481,10 @@ int lg4ff_deinit(struct hid_device *hid)
}
if (!found) {
- dbg_hid("Device entry not found!\n");
+ hid_err(hid, "Device entry not found!\n");
return -1;
}
- device_remove_file(&hid->dev, &dev_attr_range);
dbg_hid("Device successfully unregistered\n");
return 0;
}