aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-lg4ff.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2011-08-19 04:00:55 -0400
committerJiri Kosina <jkosina@suse.cz>2011-08-23 04:44:44 -0400
commit8f25229026c89912574558d0a4e36c8fe51b9bb4 (patch)
treee6a1e622a63c3266459c2952389876093798e045 /drivers/hid/hid-lg4ff.c
parent2bbaf771eb69f7fd333c4708fd76f94a3bdaf207 (diff)
HID: hid-lg4ff: add a kfree() to an error path
There is a small rare potential memory leak here. Also Walter Harms points out that we can do a small cleanup as well by using kstrdup(). Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-lg4ff.c')
-rw-r--r--drivers/hid/hid-lg4ff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 2d8762d4f32a..103f30d93f76 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -435,12 +435,12 @@ int lg4ff_init(struct hid_device *hid)
435 hid_err(hid, "Cannot add device, insufficient memory.\n"); 435 hid_err(hid, "Cannot add device, insufficient memory.\n");
436 return -ENOMEM; 436 return -ENOMEM;
437 } 437 }
438 entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL); 438 entry->device_id = kstrdup((&hid->dev)->kobj.name, GFP_KERNEL);
439 if (!entry->device_id) { 439 if (!entry->device_id) {
440 hid_err(hid, "Cannot set device_id, insufficient memory.\n"); 440 hid_err(hid, "Cannot set device_id, insufficient memory.\n");
441 kfree(entry);
441 return -ENOMEM; 442 return -ENOMEM;
442 } 443 }
443 strcpy(entry->device_id, (&hid->dev)->kobj.name);
444 entry->min_range = lg4ff_devices[i].min_range; 444 entry->min_range = lg4ff_devices[i].min_range;
445 entry->max_range = lg4ff_devices[i].max_range; 445 entry->max_range = lg4ff_devices[i].max_range;
446 entry->set_range = lg4ff_devices[i].set_range; 446 entry->set_range = lg4ff_devices[i].set_range;