i2c_smbus_read_byte_data() returns a negative error code on failure. Storing the result in a u8 truncates that error and causes probe to report a bogus chip ID and return -ENODEV. Store the result in an int and propagate read failures before checking the chip ID. An AI coding assistant was used to identify the issue and help develop the fix. The change was compile-tested with W=1. No hardware testing was performed. Fixes: c7dd343a3756 ("leds: as3668: Driver for the ams Osram 4-channel i2c LED driver") Cc: stable@vger.kernel.org Signed-off-by: Siqi Chen --- drivers/leds/leds-as3668.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-as3668.c b/drivers/leds/leds-as3668.c index 46427fe752a8..6e4b6ad59059 100644 --- a/drivers/leds/leds-as3668.c +++ b/drivers/leds/leds-as3668.c @@ -131,10 +131,13 @@ static int as3668_dt_init(struct as3668 *as3668) static int as3668_probe(struct i2c_client *client) { struct as3668 *as3668; - int err; - u8 chip_id; + int chip_id, err; chip_id = i2c_smbus_read_byte_data(client, AS3668_CHIP_ID1_REG); + if (chip_id < 0) + return dev_err_probe(&client->dev, chip_id, + "failed to read chip ID\n"); + if (chip_id != AS3668_CHIP_ID) return dev_err_probe(&client->dev, -ENODEV, "expected chip ID 0x%02x, got 0x%02x\n", -- 2.20.1