From: Philipp Zabel <p.zabel@pengutronix.de>
To: kr494167@gmail.com
Cc: gary.yang@cixtech.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] reset: sky1: propagate regmap errors and validate signals
Date: Fri, 24 Jul 2026 13:51:24 +0200 [thread overview]
Message-ID: <9ae7bf8ebb8a9b297582cbb992240f5f3e078134.camel@pengutronix.de> (raw)
In-Reply-To: <20260724044210.31592-1-kr494167@gmail.com>
On Fr, 2026-07-24 at 10:12 +0530, kr494167@gmail.com wrote:
> From: Surendra Singh Chouhan <kr494167@gmail.com>
>
> sky1_reset_assert(), sky1_reset_deassert(), sky1_reset(), and
> sky1_reset_status() ignored the return values of sky1_reset_set() and
> regmap_read(). If regmap operations failed (e.g. due to bus I/O errors),
Which bus I/O errors cause error return values?
The regmap behind this is MMIO.
> error codes were swallowed and functions returned success (0) or incorrect
> status (1).
>
> In addition, sky1_src_signals is a sparse array containing unmapped entries
> (offset == 0 && bit == 0).
This is not true. Please point out the alleged unmapped entries.
> Out-of-bounds id lookups or references to
> unmapped entries were not validated before performing regmap operations.
>
> Fix these by capturing and propagating regmap read/write errors across
> all ops, and adding bounds and unmapped signal validation in
> sky1_reset_set() and sky1_reset_status().
>
> Fixes: 7cd3ca90d921 ("reset: add Sky1 soc reset support")
> Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
> ---
> drivers/reset/reset-sky1.c | 54 +++++++++++++++++++++++++++++++-------
> 1 file changed, 44 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/reset/reset-sky1.c b/drivers/reset/reset-sky1.c
> index 78e80a533c39..885eb9563ef8 100644
> --- a/drivers/reset/reset-sky1.c
> +++ b/drivers/reset/reset-sky1.c
> @@ -267,8 +267,17 @@ static int sky1_reset_set(struct reset_controller_dev *rcdev,
> unsigned long id, bool assert)
> {
> struct sky1_src *sky1src = to_sky1_src(rcdev);
> - const struct sky1_src_signal *signal = &sky1src->signals[id];
> - unsigned int value = assert ? 0 : signal->bit;
> + const struct sky1_src_signal *signal;
> + unsigned int value;
> +
> + if (id >= sky1src->rcdev.nr_resets)
> + return -EINVAL;
This is unnecessary. The id field of struct reset_control, where this
id comes from, is set up after checking exactly this in
fwnode_reset_simple_xlate().
> +
> + signal = &sky1src->signals[id];
> + if (!signal->offset && !signal->bit)
> + return -EINVAL;
This is unnecessary. All array entries should contain a bit value.
> +
> + value = assert ? 0 : signal->bit;
>
> return regmap_update_bits(sky1src->regmap,
> signal->offset, signal->bit, value);
>
[...]
> static int sky1_reset_status(struct reset_controller_dev *rcdev,
> unsigned long id)
> {
> - unsigned int value = 0;
> struct sky1_src *sky1src = to_sky1_src(rcdev);
> - const struct sky1_src_signal *signal = &sky1src->signals[id];
> + const struct sky1_src_signal *signal;
> + unsigned int value = 0;
> + int ret;
> +
> + if (id >= sky1src->rcdev.nr_resets)
> + return -EINVAL;
> +
> + signal = &sky1src->signals[id];
> + if (!signal->offset && !signal->bit)
> + return -EINVAL;
Both unnecessary, see above.
> +
> + ret = regmap_read(sky1src->regmap, signal->offset, &value);
> + if (ret)
> + return ret;
>
> - regmap_read(sky1src->regmap, signal->offset, &value);
> return !(value & signal->bit);
> }
>
regards
Philipp
prev parent reply other threads:[~2026-07-24 11:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 4:42 kr494167
2026-07-24 11:51 ` Philipp Zabel [this message]
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=9ae7bf8ebb8a9b297582cbb992240f5f3e078134.camel@pengutronix.de \
--to=p.zabel@pengutronix.de \
--cc=gary.yang@cixtech.com \
--cc=kr494167@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®