drivers/iio/adc/ad7173.c | 474 +++++++++++++++++---------------- drivers/iio/adc/ad_sigma_delta.c | 5 +- include/linux/iio/adc/ad_sigma_delta.h | 2 - 3 files changed, 249 insertions(+), 232 deletions(-)
While working ad7124, Uwe pointed out a bug in the ad7173 driver.
static struct ad_sigma_delta_info ad7173_sigma_delta_info was not const
and was being modified during driver probe, which could lead to race
conditions if two instances of the driver were probed at the same time.
The actual fix part is fairly trivial but I have only compile tested it.
Guillaume has access to ad4111 hardware, so it would be good to get a
Tested-by from him to make sure this doesn't break anything.
---
Changes in v2:
- Fixed chip name in a few places.
- Add new simpler patch for "fix" that gets backported.
- Rebase other patches on this and incorporate feedback.
- Link to v1: https://lore.kernel.org/r/20241122-iio-adc-ad7313-fix-non-const-info-struct-v1-0-d05c02324b73@baylibre.com
---
David Lechner (3):
iio: adc: ad7173: fix using shared static info struct
iio: adc: ad7173: remove special handling for irq number
iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct
drivers/iio/adc/ad7173.c | 474 +++++++++++++++++----------------
drivers/iio/adc/ad_sigma_delta.c | 5 +-
include/linux/iio/adc/ad_sigma_delta.h | 2 -
3 files changed, 249 insertions(+), 232 deletions(-)
---
base-commit: 9dd2270ca0b38ee16094817f4a53e7ba78e31567
change-id: 20241122-iio-adc-ad7313-fix-non-const-info-struct-92e59b91ee2e
Best regards,
--
David Lechner <dlechner@baylibre.com>
On Wed, 27 Nov 2024 14:01:52 -0600 David Lechner <dlechner@baylibre.com> wrote: > While working ad7124, Uwe pointed out a bug in the ad7173 driver. > static struct ad_sigma_delta_info ad7173_sigma_delta_info was not const > and was being modified during driver probe, which could lead to race > conditions if two instances of the driver were probed at the same time. > > The actual fix part is fairly trivial but I have only compile tested it. > Guillaume has access to ad4111 hardware, so it would be good to get a > Tested-by from him to make sure this doesn't break anything. > This is very big for a backport. So I replied to previous version to suggest instead duplicating the data before modifying. That has much less code movement and maybe a cleaner fix. Perhaps we then cycle back to avoiding that copy later. Jonathan > --- > Changes in v2: > - Fixed chip name in a few places. > - Add new simpler patch for "fix" that gets backported. > - Rebase other patches on this and incorporate feedback. > - Link to v1: https://lore.kernel.org/r/20241122-iio-adc-ad7313-fix-non-const-info-struct-v1-0-d05c02324b73@baylibre.com > > --- > David Lechner (3): > iio: adc: ad7173: fix using shared static info struct > iio: adc: ad7173: remove special handling for irq number > iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct > > drivers/iio/adc/ad7173.c | 474 +++++++++++++++++---------------- > drivers/iio/adc/ad_sigma_delta.c | 5 +- > include/linux/iio/adc/ad_sigma_delta.h | 2 - > 3 files changed, 249 insertions(+), 232 deletions(-) > --- > base-commit: 9dd2270ca0b38ee16094817f4a53e7ba78e31567 > change-id: 20241122-iio-adc-ad7313-fix-non-const-info-struct-92e59b91ee2e > > Best regards,
On 11/30/24 12:43 PM, Jonathan Cameron wrote: > On Wed, 27 Nov 2024 14:01:52 -0600 > David Lechner <dlechner@baylibre.com> wrote: > >> While working ad7124, Uwe pointed out a bug in the ad7173 driver. >> static struct ad_sigma_delta_info ad7173_sigma_delta_info was not const >> and was being modified during driver probe, which could lead to race >> conditions if two instances of the driver were probed at the same time. >> >> The actual fix part is fairly trivial but I have only compile tested it. >> Guillaume has access to ad4111 hardware, so it would be good to get a >> Tested-by from him to make sure this doesn't break anything. >> > This is very big for a backport. So I replied to previous version to suggest > instead duplicating the data before modifying. That has much less code > movement and maybe a cleaner fix. Perhaps we then cycle back to avoiding > that copy later. > That is exactly what I did in v2. "iio: adc: ad7173: fix using shared static info struct" copies the struct before modifying it and is the only patch with a Fixes: tag.
On Sat, 30 Nov 2024 12:50:39 -0600 David Lechner <dlechner@baylibre.com> wrote: > On 11/30/24 12:43 PM, Jonathan Cameron wrote: > > On Wed, 27 Nov 2024 14:01:52 -0600 > > David Lechner <dlechner@baylibre.com> wrote: > > > >> While working ad7124, Uwe pointed out a bug in the ad7173 driver. > >> static struct ad_sigma_delta_info ad7173_sigma_delta_info was not const > >> and was being modified during driver probe, which could lead to race > >> conditions if two instances of the driver were probed at the same time. > >> > >> The actual fix part is fairly trivial but I have only compile tested it. > >> Guillaume has access to ad4111 hardware, so it would be good to get a > >> Tested-by from him to make sure this doesn't break anything. > >> > > This is very big for a backport. So I replied to previous version to suggest > > instead duplicating the data before modifying. That has much less code > > movement and maybe a cleaner fix. Perhaps we then cycle back to avoiding > > that copy later. > > > That is exactly what I did in v2. "iio: adc: ad7173: fix using shared > static info struct" copies the struct before modifying it and is the > only patch with a Fixes: tag. > Oops - brain fart. Applied patch 1 for now to the fixes-togreg branch of iio.git and marked it for stable. I'll get the others once that's upstream. Thanks, Jonathan
On Wed, 27 Nov 2024 21:01, David Lechner <dlechner@baylibre.com> wrote: >While working ad7124, Uwe pointed out a bug in the ad7173 driver. >static struct ad_sigma_delta_info ad7173_sigma_delta_info was not const >and was being modified during driver probe, which could lead to race >conditions if two instances of the driver were probed at the same time. > >The actual fix part is fairly trivial but I have only compile tested it. >Guillaume has access to ad4111 hardware, so it would be good to get a >Tested-by from him to make sure this doesn't break anything. > >--- >Changes in v2: >- Fixed chip name in a few places. >- Add new simpler patch for "fix" that gets backported. >- Rebase other patches on this and incorporate feedback. >- Link to v1: https://lore.kernel.org/r/20241122-iio-adc-ad7313-fix-non-const-info-struct-v1-0-d05c02324b73@baylibre.com > >--- >David Lechner (3): > iio: adc: ad7173: fix using shared static info struct > iio: adc: ad7173: remove special handling for irq number > iio: adc: ad7173: don't make copy of ad_sigma_delta_info struct > > drivers/iio/adc/ad7173.c | 474 +++++++++++++++++---------------- > drivers/iio/adc/ad_sigma_delta.c | 5 +- > include/linux/iio/adc/ad_sigma_delta.h | 2 - > 3 files changed, 249 insertions(+), 232 deletions(-) >--- >base-commit: 9dd2270ca0b38ee16094817f4a53e7ba78e31567 >change-id: 20241122-iio-adc-ad7313-fix-non-const-info-struct-92e59b91ee2e > >Best regards, >-- >David Lechner <dlechner@baylibre.com> Tested-by: Guillaume Ranquet <granquet@baylibre.com>
© 2016 - 2026 Red Hat, Inc.