From 706a066328dbdd7a15ac4904905fa7f8bd29cdf0 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 18 Aug 2024 21:58:00 -0700 Subject: [PATCH] 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 Link: https://lore.kernel.org/r/20240819045813.2154642-4-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index b0e22903bb1c..ada4cd151dc6 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -349,8 +349,11 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size, GFP_KERNEL); + if (!keypad) + return -ENOMEM; + input_dev = devm_input_allocate_device(&pdev->dev); - if (!keypad || !input_dev) + if (!input_dev) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -- 2.47.2