iio: dac: mcp47feb02: Fix mutex used before initialization
Subsystems (2)
PATCH v2 1/1 iio: dac: mcp47feb02: Fix mutex used before initialization
The mcp47feb02_parse_fw() function uses data->lock, but the mutex was initialized after this function in probe path.
Since mcp47feb02_parse_fw() is only called from probe(), remove the lock.
---
Changes in v2:
- Remove the lock in mcp47feb02_parse_fw() suggested by Nuno Sá.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/iio/dac/mcp47feb02.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/dac/mcp47feb02.c +0 -2
@@ -955,8 +955,6 @@ static int mcp47feb02_parse_fw(struct iio_dev *indio_dev,u32 num_channels;u8 chan_idx =0 ; -guard (mutex)(&data->lock); - num_channels =device_get_child_node_count (dev);if (num_channels > chip_features->phys_channels)return dev_err_probe (dev, -EINVAL ,"More channels than the chip supports\n" );
---
base-commit: d4906ae14a5f136ceb671bb14cedbf13fa560da6
change-id: 20260223-mcp47feb02-e0bed17e198b
Best regards,
Signature · 1 line
Felix Gu <[email protected]>
Quoted 4 lines · Felix Gu
The
mcp47feb02_parse_fw()function usesdata->lock, but the mutex was initialized after this function in probe path.Since
mcp47feb02_parse_fw()is only called fromprobe(), remove the lock.
But is it called early enough before anything that may trigger access to 'data'? Exempli gratia, IRQ handler in some cases may be triggered before probe finished (is it the case here?).
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): CAN4SLj3jw-SqXSV04CA_-d=e=Mu63xaJuzu1rUYzTtt7myqMKw@mail.gmail.com
Andy Shevchenko
Reviewed-byQuoted 5 lines · Felix Gu
Quoted 4 lines
But is it called early enough before anything that may trigger access to 'data'? Exempli gratia, IRQ handler in some cases may be triggered before probe finished (is it the case here?).
I've checked the implementation, and this driver does not support IRQs.
Thanks for confirming!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · On Thu, 26 Feb 2026 15:18:59 +0200 Andy Shevchenko…
Quoted 5 lines · Felix Gu
Quoted 4 lines
But is it called early enough before anything that may trigger access to 'data'? Exempli gratia, IRQ handler in some cases may be triggered before probe finished (is it the case here?).
I've checked the implementation, and this driver does not support IRQs.
Thanks for confirming!
Reviewed-by Andy Shevchenko <[email protected]>
Applied.
Thanks,
Jonathan