You need to sign in or sign up before continuing.
提交 b034ed50 编写于 作者: G Gustavo A. R. Silva 提交者: Jiri Kosina

HID: core: fix NULL pointer dereference

There is a NULL pointer dereference in case memory resources
for *parse* are not successfully allocated.

Fix this by adding a new goto label and make the execution
path jump to it in case vzalloc() fails.

Addresses-Coverity-ID: 1473081 ("Dereference after null check")
Fixes: b2dd9f2e ("HID: core: fix memory leak on probe")
Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: NStefan Agner <stefan@agner.ch>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 0d6c3011
...@@ -1000,7 +1000,7 @@ int hid_open_report(struct hid_device *device) ...@@ -1000,7 +1000,7 @@ int hid_open_report(struct hid_device *device)
parser = vzalloc(sizeof(struct hid_parser)); parser = vzalloc(sizeof(struct hid_parser));
if (!parser) { if (!parser) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto alloc_err;
} }
parser->device = device; parser->device = device;
...@@ -1049,6 +1049,7 @@ int hid_open_report(struct hid_device *device) ...@@ -1049,6 +1049,7 @@ int hid_open_report(struct hid_device *device)
hid_err(device, "item fetching failed at offset %d\n", (int)(end - start)); hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
err: err:
kfree(parser->collection_stack); kfree(parser->collection_stack);
alloc_err:
vfree(parser); vfree(parser);
hid_close_report(device); hid_close_report(device);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册