linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Malý" <madcatxster@gmail.com>
To: linux-input@vger.kernel.org, jkosina@suse.cz, simon@mungewell.org
Subject: [PATCH v4] HID: lg4ff: Remove sysfs iface before deallocating memory
Date: Sat, 31 Mar 2012 11:35:05 +0200	[thread overview]
Message-ID: <2198552.DMoMTvshKQ@qosmio-x300> (raw)

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

Hi,

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.
Please note that this patch depends on "hid-lg: Allow for custom
device-specific properties to be stored in private drv data" because
it also fixes a tiny glitch - a leftover #include in the hid-lg.h

I have another lg4ff patch pending that makes use of the new possibility to
store device-specific data which is currently being review by Simon.
The patch as it is right now will depend on this patch.

Signed-off-by: Michal Malý <madcatsxter@gmail.com>

---
 drivers/hid/hid-lg.h    |    2 --
 drivers/hid/hid-lg4ff.c |    6 ++++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-lg.h b/drivers/hid/hid-lg.h
index 500457b..d64cf8d 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 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;
 }
-- 
1.7.9.5


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

             reply	other threads:[~2012-03-31  9:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-31  9:35 Michal Malý [this message]
2012-04-02  1:49 ` [PATCH v4] HID: lg4ff: Remove sysfs iface before deallocating memory simon
2012-04-02 14:54   ` [PATCH 1/2] HID: hid-lg4ff: Use Private Data Simon Wood
2012-04-02 14:54     ` [PATCH 2/2] HID: hid-lg4ff: Add support for G27 leds Simon Wood
2012-04-02 16:38       ` Jiri Slaby
2012-04-02 16:32     ` [PATCH 1/2] HID: hid-lg4ff: Use Private Data Jiri Slaby
2012-04-02 17:01       ` simon
2012-04-02 17:30         ` Jiri Slaby
2012-04-03  2:14         ` Jiri Kosina
2012-04-03  2:13     ` Jiri Kosina
2012-04-03  8:02       ` Michal Malý
2012-04-03  2:12 ` [PATCH v4] HID: lg4ff: Remove sysfs iface before deallocating memory Jiri Kosina

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=2198552.DMoMTvshKQ@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).