mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
leds: pca9532: Fix phantom device registration on missing hardware
The initial PWM and PSC register writes in pca9532_configure() do not
check the return values of i2c_smbus_write_byte_data(). If the I2C
device is physically absent from the bus, the write fails with -ENXIO.
However, the driver ignores this error and allows probe() to complete
successfully.
This results in the registration of phantom LED class devices and
gpiochips backed by non-existent hardware. Subsequent GPIO reads from
these phantom chips return bogus values (due to -ENXIO being truncated
to an unsigned char in pca9532_gpio_get_value()), silently corrupting
hardware state tracking in userspace.
Propagate the I2C write failures back to probe() so the driver core
can gracefully abort binding and release devres-managed resources.
Fixes: e14fa82439 ("leds: Add pca9532 led driver")
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260715080747.1638097-1-chou.cosmo@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
98c5c7b0d4
commit
8d6b6c05b8
|
|
@ -397,10 +397,14 @@ static int pca9532_configure(struct i2c_client *client,
|
|||
for (i = 0; i < 2; i++) {
|
||||
data->pwm[i] = pdata->pwm[i];
|
||||
data->psc[i] = pdata->psc[i];
|
||||
i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(maxleds, i),
|
||||
data->pwm[i]);
|
||||
i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(maxleds, i),
|
||||
data->psc[i]);
|
||||
err = i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(maxleds, i),
|
||||
data->pwm[i]);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(maxleds, i),
|
||||
data->psc[i]);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
data->hw_blink = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user