linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Malý" <madcatxster@gmail.com>
To: linux-input@vger.kernel.org
Cc: jkosina@suse.cz, simon@mungewell.org
Subject: [PATCHv2 2/3] HID: hid-lg4ff: Fix sysfs vs memory deallocation race condition
Date: Wed, 14 Mar 2012 18:32:24 +0100	[thread overview]
Message-ID: <1838680.SEvr9qg2Jd@qosmio-x300> (raw)

[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]

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@gmail.com>

>From 267123534c3605011cebde0244e384de210cf901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Mal=C3=BD?= <madcatxster@gmail.com>
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 #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

                 reply	other threads:[~2012-03-14 17:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1838680.SEvr9qg2Jd@qosmio-x300 \
    --to=madcatxster@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=simon@mungewell.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).