Skip to content

Commit 929b60a

Browse files
GustavoARSilvaJiri Kosina
authored andcommitted
HID: hid-logitech-hidpp: add NULL check on devm_kmemdup() return value
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>
1 parent 4cf56a8 commit 929b60a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,9 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp)
27322732
hidpp_battery_props,
27332733
sizeof(hidpp_battery_props),
27342734
GFP_KERNEL);
2735+
if (!battery_props)
2736+
return -ENOMEM;
2737+
27352738
num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2;
27362739

27372740
if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE)

0 commit comments

Comments
 (0)