From 6a2e176b2d6ae6bb528c0c1a50a6332e176cda12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Mal=C3=BD?= Date: Sat, 31 Mar 2012 11:35:05 +0200 Subject: HID: lg4ff: Remove sysfs iface before deallocating memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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Ă˝ Signed-off-by: Jiri Kosina --- drivers/hid/hid-lg4ff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/hid/hid-lg4ff.c') diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 6ecc9e2..1145292 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; } -- cgit v1.1