[PATCHv2 2/3] HID: hid-lg4ff: Fix sysfs vs memory deallocation race condition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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ý <madcatxster@xxxxxxxxx>

>From 267123534c3605011cebde0244e384de210cf901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal Malý?= <madcatxster@xxxxxxxxx>
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

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux