]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Input: samsung-keypad - do not combine memory allocation checks
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 19 Aug 2024 04:58:00 +0000 (21:58 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 1 Jul 2025 21:15:58 +0000 (14:15 -0700)
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>
drivers/input/keyboard/samsung-keypad.c

index b0e22903bb1cfe8b15e6d295f47ead42c50411ac..ada4cd151dc6cbdb42de29c019a74b0093ebe000 100644 (file)
@@ -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);