From: Lee Jones <lee@kernel.org>
To: shao.mingyin@zte.com.cn
Cc: mfd@lists.linux.dev, tony@atomide.com,
linux-omap@vger.kernel.org, tharvey@gateworks.com,
support.opensource@diasemi.com, patches@opensource.cirrus.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] mfd: gateworks-gsc: Check firmware CRC reads for errors
Date: Wed, 18 Nov 2026 18:22:40 +0000 [thread overview]
Message-ID: <20261118182240.GH98456@joneslee-macbookpro.roam.internal> (raw)
In-Reply-To: <20261107160748370uUkky_wRKP7vtnKU1uRKZ@zte.com.cn>
On Sat, 07 Nov 2026, shao.mingyin@zte.com.cn wrote:
> From: Shao Mingyin <shao.mingyin@zte.com.cn>
>
> gsc_probe() checks the return value of the GSC_FW_VER regmap_read() but
> the two reads of GSC_FW_CRC just below it are not checked. On an I2C
> error regmap_read() leaves "reg" holding the value of the previous
> successful read (the firmware version, or the CRC low byte), so
> gsc->fwcrc ends up with a wrong value that is later printed as the
> firmware revision, and the error is silently ignored.
>
> Check both CRC reads and fail the probe with -EIO, matching the handling
> of the version read above.
>
> Fixes: d85234994b2f ("mfd: Add Gateworks System Controller core driver")
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
> diff --git a/drivers/mfd/gateworks-gsc.c b/drivers/mfd/gateworks-gsc.c
> index a3301502ce6a..1d697e82ea29 100644
> --- a/drivers/mfd/gateworks-gsc.c
> +++ b/drivers/mfd/gateworks-gsc.c
> @@ -219,9 +219,11 @@ static int gsc_probe(struct i2c_client *client)
> return -EIO;
> gsc->fwver = reg;
>
> - regmap_read(gsc->regmap, GSC_FW_CRC, ®);
> + if (regmap_read(gsc->regmap, GSC_FW_CRC, ®))
> + return -EIO;
Again, I'd rather you didn't put functions in if() statements.
But worse, you're hiding the real error and forcing -EIO.
Better to propagate the error instead.
> gsc->fwcrc = reg;
> - regmap_read(gsc->regmap, GSC_FW_CRC + 1, ®);
> + if (regmap_read(gsc->regmap, GSC_FW_CRC + 1, ®))
> + return -EIO;
> gsc->fwcrc |= reg << 8;
>
> gsc->i2c_hwmon = devm_i2c_new_dummy_device(dev, client->adapter,
--
Lee Jones
prev parent reply other threads:[~2026-11-18 18:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 8:07 [PATCH 0/5] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
2026-11-07 8:07 ` [PATCH 1/5] mfd: tps65219: Fix out-of-bounds access in tps65214 IRQ map shao.mingyin
2026-11-18 17:46 ` Lee Jones
2026-11-07 8:07 ` [PATCH 2/5] mfd: twl6030-irq: Don't write garbage to interrupt mask on read failure shao.mingyin
2026-11-07 8:07 ` [PATCH 3/5] mfd: arizona: Free info IRQs on probe failure shao.mingyin
2026-11-18 17:50 ` Lee Jones
2026-11-07 8:07 ` [PATCH 4/5] mfd: da9052: Disable IRQ wake on device removal shao.mingyin
2026-11-18 17:57 ` Lee Jones
2026-11-07 8:07 ` [PATCH 5/5] mfd: gateworks-gsc: Check firmware CRC reads for errors shao.mingyin
2026-11-18 18:22 ` Lee Jones [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=20261118182240.GH98456@joneslee-macbookpro.roam.internal \
--to=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=patches@opensource.cirrus.com \
--cc=shao.mingyin@zte.com.cn \
--cc=support.opensource@diasemi.com \
--cc=tharvey@gateworks.com \
--cc=tony@atomide.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
all inboxes | Powered by JetHome®