public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Anas Iqbal <mohd.abd.6602@gmail.com>
To: mturquette@baylibre.com, sboyd@kernel.org, linux-clk@vger.kernel.org
Cc: hayashi.kunihiko@socionext.com, mhiramat@kernel.org,
	yamada.masahiro@socionext.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Anas Iqbal <mohd.abd.6602@gmail.com>
Subject: [PATCH] clk: uniphier: mux: fix signedness bug in get_parent
Date: Wed, 18 Mar 2026 11:02:51 +0000	[thread overview]
Message-ID: <20260318110251.2412-1-mohd.abd.6602@gmail.com> (raw)

The uniphier_clk_mux_get_parent() function returns a u8, but
propagates negative error codes such as -EINVAL and regmap_read()
failures. These values are implicitly converted to large unsigned
integers, resulting in invalid parent indices.

The clk_ops.get_parent() callback is expected to return a valid
parent index and does not support error codes. Fix this by returning
0 as a safe fallback in error cases.

Fixes: 734d82f4a678 ("clk: uniphier: add core support code for UniPhier clock driver")
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
---
 drivers/clk/uniphier/clk-uniphier-mux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/uniphier/clk-uniphier-mux.c b/drivers/clk/uniphier/clk-uniphier-mux.c
index 1998e9d4cfc0..f3b21ea96649 100644
--- a/drivers/clk/uniphier/clk-uniphier-mux.c
+++ b/drivers/clk/uniphier/clk-uniphier-mux.c
@@ -38,13 +38,13 @@ static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw)
 
 	ret = regmap_read(mux->regmap, mux->reg, &val);
 	if (ret)
-		return ret;
+		return 0; /* fallback to parent 0 on error */
 
 	for (i = 0; i < num_parents; i++)
 		if ((mux->masks[i] & val) == mux->vals[i])
 			return i;
 
-	return -EINVAL;
+	return 0; /* default fallback */
 }
 
 static const struct clk_ops uniphier_clk_mux_ops = {
-- 
2.43.0



             reply	other threads:[~2026-03-18 11:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 11:02 Anas Iqbal [this message]
2026-03-18 17:05 ` [PATCH] clk: uniphier: mux: fix signedness bug in get_parent Brian Masney
2026-03-24  0:44 ` Stephen Boyd
2026-03-25  5:11   ` Kunihiko Hayashi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260318110251.2412-1-mohd.abd.6602@gmail.com \
    --to=mohd.abd.6602@gmail.com \
    --cc=hayashi.kunihiko@socionext.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox