HID: hid-lg4ff: Fix sysfs vs memory deallocation race condition

Started by Michal Malý on Mar 14, 2012

Subsystems (2)

Maintainers (3)

DORMANTno replies

open the first message on its own page

Message details and related content
The device specific data stored in the linked list were removed before the sysfs attrs were
properly removed. This patch corrects this issue

Signed-off-by: Michal Malý <redacted>
From 267123534c3605011cebde0244e384de210cf901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Mal=C3=BD?= <redacted>
Date: Wed, 14 Mar 2012 18:15:37 +0100
Subject: [PATCH 2/2] HID: lg4ff: Remove the sysfs interface before
 deallocating memory

---
 drivers/hid/hid-lg4ff.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 6ecc9e2..f70ae41 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");
+		dbg_err("Device entry not found!\n");
 		return -1;
 	}
 
-	device_remove_file(&hid->dev, &dev_attr_range);
 	dbg_hid("Device successfully unregistered\n");
 	return 0;
 }
-- 
1.7.9.4
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help