提交 6a2e176b 编写于 作者: M Michal Malý 提交者: Jiri Kosina

HID: lg4ff: Remove sysfs iface before deallocating memory

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: NMichal Malý <madcatsxter@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 8577dbf9
#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 */
......
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册