Skip to content

Commit 491403b

Browse files
abdurrahman-nexthopgroeck
authored andcommitted
hwmon: (pmbus/adm1266) register the gpio_chip after pmbus_do_probe()
adm1266_probe() calls adm1266_config_gpio() -- which goes on to devm_gpiochip_add_data() and exposes the gpio_chip callbacks to gpiolib -- before pmbus_do_probe() has initialised the per-client PMBus state (notably the pmbus_lock mutex the core hands out via pmbus_get_data()). That ordering is already a latent hazard: any GPIO access that lands between adm1266_config_gpio() and the end of pmbus_do_probe() (for example a sysfs read from a user space agent that opens the gpiochip the instant gpiolib advertises it) races pmbus_do_probe()'s own device accesses with no serialisation. Move adm1266_config_gpio() down past pmbus_do_probe() so the chip isn't reachable from userspace until the PMBus state it depends on is fully initialised. Fixes: d98dfad ("hwmon: (pmbus/adm1266) Add support for GPIOs") Cc: stable@vger.kernel.org Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260518-adm1266-gpio-fixes-v3-4-e425e4f88139@nexthop.ai Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent a7232f6 commit 491403b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/hwmon/pmbus/adm1266.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,6 @@ static int adm1266_probe(struct i2c_client *client)
473473
crc8_populate_msb(pmbus_crc_table, 0x7);
474474
mutex_init(&data->buf_mutex);
475475

476-
ret = adm1266_config_gpio(data);
477-
if (ret < 0)
478-
return ret;
479-
480476
ret = adm1266_set_rtc(data);
481477
if (ret < 0)
482478
return ret;
@@ -489,6 +485,10 @@ static int adm1266_probe(struct i2c_client *client)
489485
if (ret)
490486
return ret;
491487

488+
ret = adm1266_config_gpio(data);
489+
if (ret < 0)
490+
return ret;
491+
492492
adm1266_init_debugfs(data);
493493

494494
return 0;

0 commit comments

Comments
 (0)