diff mbox series

[03/14] Input: samsung-keypad - do not combine memory allocation checks

Message ID 20240819045813.2154642-4-dmitry.torokhov@gmail.com (mailing list archive)
State New
Headers show
Series Remove support for platform data from samsung keypad | expand

Commit Message

Dmitry Torokhov Aug. 19, 2024, 4:58 a.m. UTC
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.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/keyboard/samsung-keypad.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Aug. 19, 2024, 12:52 p.m. UTC | #1
On Sun, Aug 18, 2024 at 09:58:00PM -0700, Dmitry Torokhov wrote:
> 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.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/keyboard/samsung-keypad.c | 5 ++++-

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 46c0d0c900f6..2be3bfa87ce1 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);