Skip to content

Commit

Permalink
HID: hid-logitech-hidpp: add NULL check on devm_kmemdup() return value
Browse files Browse the repository at this point in the history
Check return value from call to devm_kmemdup() in order to prevent a NULL
pointer dereference.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Gustavo A. R. Silva authored and Jiri Kosina committed Jul 20, 2017
1 parent 4cf56a8 commit 929b60a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/hid/hid-logitech-hidpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,9 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp)
hidpp_battery_props,
sizeof(hidpp_battery_props),
GFP_KERNEL);
if (!battery_props)
return -ENOMEM;

num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2;

if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE)
Expand Down

0 comments on commit 929b60a

Please sign in to comment.