[PATCH] ARM: OMAP1: Fix error handling path in omap1_dm_timer_init()

DORMANTno replies

From: Christophe JAILLET <hidden>
Date: 2022-04-22 14:18:29
Also in: kernel-janitors, linux-omap, lkml
Subsystem: arm port, omap1 support, the rest · Maintainers: Russell King, Aaro Koskinen, Janusz Krzysztofik, Linus Torvalds

platform_device_put() should be called instead of
platform_device_unregister() in the error handling path because, at this
point, no successful platform_device_add() has been called.

While at it, change the goto label if kzalloc() fails. It is harmless to
call 'kfree(NULL)', but it is also pointless.

Fixes: 97933d6ced60 ("ARM: OMAP1: dmtimer: conversion to platform devices")
Signed-off-by: Christophe JAILLET <redacted>
---
This is a speculative patch, not even compile tested because of lack of
cross-compiler.
So review with care.
---
 arch/arm/mach-omap1/timer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap1/timer.c b/arch/arm/mach-omap1/timer.c
index 0411d5508d63..f91ba2353345 100644
--- a/arch/arm/mach-omap1/timer.c
+++ b/arch/arm/mach-omap1/timer.c
@@ -135,7 +135,7 @@ static int __init omap1_dm_timer_init(void)
 		pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
 		if (!pdata) {
 			ret = -ENOMEM;
-			goto err_free_pdata;
+			goto err_free_pdev;
 		}
 
 		pdata->set_timer_src = omap1_dm_timer_set_src;
@@ -165,7 +165,7 @@ static int __init omap1_dm_timer_init(void)
 	kfree(pdata);
 
 err_free_pdev:
-	platform_device_unregister(pdev);
+	platform_device_put(pdev);
 
 	return ret;
 }
-- 
2.32.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help