public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive()
@ 2026-02-05  8:40 Chen Ni
  2026-02-24 14:51 ` Chen-Yu Tsai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chen Ni @ 2026-02-05  8:40 UTC (permalink / raw)
  To: daniel.lezcano, tglx, wens, jernej.skrabec, samuel, p.zabel,
	mripard, mans
  Cc: linux-kernel, linux-arm-kernel, linux-sunxi, Chen Ni

The devm_reset_control_get_optional_exclusive() function may return an
ERR_PTR in case of genuine reset control acquisition errors, not just
NULL which indicates the legitimate absence of an optional reset.

Add an IS_ERR() check after the call in sun5i_timer_probe(). On error,
return the error code to ensure proper failure handling rather than
proceeding with invalid pointers.

Fixes: 7e5bac610d2f ("clocksource/drivers/sun5i: Convert to platform device driver")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/clocksource/timer-sun5i.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
index f827d3f98f60..d7e012992170 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -286,6 +286,9 @@ static int sun5i_timer_probe(struct platform_device *pdev)
 	}
 
 	rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(rstc))
+		return dev_err_probe(dev, PTR_ERR(rstc),
+				     "failed to get reset\n");
 	if (rstc)
 		reset_control_deassert(rstc);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive()
  2026-02-05  8:40 [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive() Chen Ni
@ 2026-02-24 14:51 ` Chen-Yu Tsai
  2026-03-04 19:35 ` Daniel Lezcano
  2026-04-12 20:39 ` [tip: timers/clocksource] " tip-bot2 for Chen Ni
  2 siblings, 0 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2026-02-24 14:51 UTC (permalink / raw)
  To: Chen Ni
  Cc: daniel.lezcano, tglx, jernej.skrabec, samuel, p.zabel, mripard,
	mans, linux-kernel, linux-arm-kernel, linux-sunxi

On Thu, Feb 5, 2026 at 4:42 PM Chen Ni <nichen@iscas.ac.cn> wrote:
>
> The devm_reset_control_get_optional_exclusive() function may return an
> ERR_PTR in case of genuine reset control acquisition errors, not just
> NULL which indicates the legitimate absence of an optional reset.
>
> Add an IS_ERR() check after the call in sun5i_timer_probe(). On error,
> return the error code to ensure proper failure handling rather than
> proceeding with invalid pointers.
>
> Fixes: 7e5bac610d2f ("clocksource/drivers/sun5i: Convert to platform device driver")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>

Acked-by: Chen-Yu Tsai <wens@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive()
  2026-02-05  8:40 [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive() Chen Ni
  2026-02-24 14:51 ` Chen-Yu Tsai
@ 2026-03-04 19:35 ` Daniel Lezcano
  2026-04-12 20:39 ` [tip: timers/clocksource] " tip-bot2 for Chen Ni
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2026-03-04 19:35 UTC (permalink / raw)
  To: Chen Ni
  Cc: daniel.lezcano, tglx, wens, jernej.skrabec, samuel, p.zabel,
	mripard, mans, linux-kernel, linux-arm-kernel, linux-sunxi

On Thu, Feb 05, 2026 at 04:40:37PM +0800, Chen Ni wrote:
> The devm_reset_control_get_optional_exclusive() function may return an
> ERR_PTR in case of genuine reset control acquisition errors, not just
> NULL which indicates the legitimate absence of an optional reset.
> 
> Add an IS_ERR() check after the call in sun5i_timer_probe(). On error,
> return the error code to ensure proper failure handling rather than
> proceeding with invalid pointers.
> 
> Fixes: 7e5bac610d2f ("clocksource/drivers/sun5i: Convert to platform device driver")
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: timers/clocksource] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive()
  2026-02-05  8:40 [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive() Chen Ni
  2026-02-24 14:51 ` Chen-Yu Tsai
  2026-03-04 19:35 ` Daniel Lezcano
@ 2026-04-12 20:39 ` tip-bot2 for Chen Ni
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Chen Ni @ 2026-04-12 20:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Chen Ni, Daniel Lezcano, Chen-Yu Tsai, x86, linux-kernel

The following commit has been merged into the timers/clocksource branch of tip:

Commit-ID:     fed9f727cc3f91dde8278961269419083502b40e
Gitweb:        https://git.kernel.org/tip/fed9f727cc3f91dde8278961269419083502b40e
Author:        Chen Ni <nichen@iscas.ac.cn>
AuthorDate:    Thu, 05 Feb 2026 16:40:37 +08:00
Committer:     Daniel Lezcano <daniel.lezcano@kernel.org>
CommitterDate: Tue, 24 Mar 2026 18:30:44 +01:00

clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive()

The devm_reset_control_get_optional_exclusive() function may return an
ERR_PTR in case of genuine reset control acquisition errors, not just
NULL which indicates the legitimate absence of an optional reset.

Add an IS_ERR() check after the call in sun5i_timer_probe(). On error,
return the error code to ensure proper failure handling rather than
proceeding with invalid pointers.

Fixes: 7e5bac610d2f ("clocksource/drivers/sun5i: Convert to platform device driver")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org>
Acked-by: Chen-Yu Tsai <wens@kernel.org>
Link: https://patch.msgid.link/20260205084037.3661261-1-nichen@iscas.ac.cn
---
 drivers/clocksource/timer-sun5i.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
index f827d3f..d7e0129 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -286,6 +286,9 @@ static int sun5i_timer_probe(struct platform_device *pdev)
 	}
 
 	rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(rstc))
+		return dev_err_probe(dev, PTR_ERR(rstc),
+				     "failed to get reset\n");
 	if (rstc)
 		reset_control_deassert(rstc);
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-12 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-05  8:40 [PATCH] clocksource/drivers/sun5i: Handle error returns from devm_reset_control_get_optional_exclusive() Chen Ni
2026-02-24 14:51 ` Chen-Yu Tsai
2026-03-04 19:35 ` Daniel Lezcano
2026-04-12 20:39 ` [tip: timers/clocksource] " tip-bot2 for Chen Ni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox