[PATCH 5/5] mfd: gateworks-gsc: Check firmware CRC reads for errors
From: shao.mingyin
Date: Sat Nov 07 2026 - 03:08:53 EST
From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
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@xxxxxxxxxx>
---
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;
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,