[patch 2/2 -next] hid-lg4ff: add a kfree() to an error path

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

 



There is a small rare potential memory leak here.  But it's easy to
fix.

Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>

diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..2b4bbcb 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -438,6 +438,7 @@ int lg4ff_init(struct hid_device *hid)
 	entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
 	if (!entry->device_id) {
 		hid_err(hid, "Cannot set device_id, insufficient memory.\n");
+		kfree(entry);
 		return -ENOMEM;
 	}
 	strcpy(entry->device_id, (&hid->dev)->kobj.name);
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux