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 <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20240819045813.2154642-4-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 4d4d74c commit 706a066

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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)