Skip to content

Commit 706a066

Browse files
committed
Input: samsung-keypad - do not combine memory allocation checks
The driver uses devm API to allocate resources so there's no reason to do allocations first and then check and release everything at once. Check results immediately after doing allocation of each resource. Reviewed-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 4d4d74c commit 706a066

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/input/keyboard/samsung-keypad.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,11 @@ static int samsung_keypad_probe(struct platform_device *pdev)
349349

350350
keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size,
351351
GFP_KERNEL);
352+
if (!keypad)
353+
return -ENOMEM;
354+
352355
input_dev = devm_input_allocate_device(&pdev->dev);
353-
if (!keypad || !input_dev)
356+
if (!input_dev)
354357
return -ENOMEM;
355358

356359
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

0 commit comments

Comments
 (0)