Commit 709d27c0 authored by Mariusz Kozlowski's avatar Mariusz Kozlowski Committed by Jiri Kosina
Browse files

HID: hidraw_connect() memleak fix

It looks like hidraw_connect() is leaking memory in case of failure.
Also it should return -ENOMEM when kzalloc fails.
Signed-off-by: default avatarMariusz Kozlowski <>
Signed-off-by: default avatarJiri Kosina <>
parent 86166b7b
......@@ -282,7 +282,7 @@ EXPORT_SYMBOL_GPL(hidraw_report_event);
int hidraw_connect(struct hid_device *hid)
int minor, result = -EINVAL;
int minor, result;
struct hidraw *dev;
/* TODO currently we accept any HID device. This should later
......@@ -290,8 +290,11 @@ int hidraw_connect(struct hid_device *hid)
* non-input applications
if (!(dev = kzalloc(sizeof(struct hidraw), GFP_KERNEL)))
return -1;
dev = kzalloc(sizeof(struct hidraw), GFP_KERNEL);
if (!dev)
return -ENOMEM;
result = -EINVAL;
......@@ -305,8 +308,10 @@ int hidraw_connect(struct hid_device *hid)
if (result)
if (result) {
goto out;
dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
"%s%d", "hidraw", minor);
......@@ -316,6 +321,7 @@ int hidraw_connect(struct hid_device *hid)
hidraw_table[minor] = NULL;
result = PTR_ERR(dev->dev);
goto out;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment