public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw
@ 2026-05-05 21:17 Salah Triki
  2026-05-05 22:05 ` Joshua Crofts
  2026-05-06  8:35 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Salah Triki @ 2026-05-05 21:17 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: linux-iio, linux-kernel, Salah Triki

The driver proceeds to the reception phase even if the preceding
transmission fails.

This uses a goto error label for an early bail out and ensures the mutex is
properly unlocked in case of failure.

Fixes: ffd8a6e7a778 ("iio: adc: Add viperboard adc driver")
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/iio/adc/viperboard_adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
index 9bb0b83c8f67..14d018b5aa33 100644
--- a/drivers/iio/adc/viperboard_adc.c
+++ b/drivers/iio/adc/viperboard_adc.c
@@ -72,6 +72,8 @@ static int vprbrd_iio_read_raw(struct iio_dev *iio_dev,
 		if (ret != sizeof(struct vprbrd_adc_msg)) {
 			dev_err(&iio_dev->dev, "usb send error on adc read\n");
 			error = -EREMOTEIO;
+			mutex_unlock(&vb->lock);
+			goto error;
 		}
 
 		ret = usb_control_msg(vb->usb_dev,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw
  2026-05-05 21:17 [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw Salah Triki
@ 2026-05-05 22:05 ` Joshua Crofts
  2026-05-05 22:19   ` Maxwell Doose
  2026-05-06  8:35 ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Joshua Crofts @ 2026-05-05 22:05 UTC (permalink / raw)
  To: Salah Triki
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

On Tue, 5 May 2026 at 23:18, Salah Triki <salah.triki@gmail.com> wrote:
>
> The driver proceeds to the reception phase even if the preceding
> transmission fails.
>
> This uses a goto error label for an early bail out and ensures the mutex is
> properly unlocked in case of failure.
>
> Fixes: ffd8a6e7a778 ("iio: adc: Add viperboard adc driver")
> Signed-off-by: Salah Triki <salah.triki@gmail.com>

Nitpick, but I would add adc into the patch title ("iio: adc: viperboard: ...").

>
> diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
> index 9bb0b83c8f67..14d018b5aa33 100644
> --- a/drivers/iio/adc/viperboard_adc.c
> +++ b/drivers/iio/adc/viperboard_adc.c
> @@ -72,6 +72,8 @@ static int vprbrd_iio_read_raw(struct iio_dev *iio_dev,
>                 if (ret != sizeof(struct vprbrd_adc_msg)) {
>                         dev_err(&iio_dev->dev, "usb send error on adc read\n");
>                         error = -EREMOTEIO;
> +                       mutex_unlock(&vb->lock);
> +                       goto error;
>                 }
>
>                 ret = usb_control_msg(vb->usb_dev,
> --
> 2.43.0

Code-wise LGTM.

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards

CJD

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw
  2026-05-05 22:05 ` Joshua Crofts
@ 2026-05-05 22:19   ` Maxwell Doose
  0 siblings, 0 replies; 4+ messages in thread
From: Maxwell Doose @ 2026-05-05 22:19 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Salah Triki, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-iio, linux-kernel

On Tue, May 5, 2026 at 5:06 PM Joshua Crofts <joshua.crofts1@gmail.com> wrote:
>
> On Tue, 5 May 2026 at 23:18, Salah Triki <salah.triki@gmail.com> wrote:
> >
> > The driver proceeds to the reception phase even if the preceding
> > transmission fails.
> >
> > This uses a goto error label for an early bail out and ensures the mutex is
> > properly unlocked in case of failure.
> >
> > Fixes: ffd8a6e7a778 ("iio: adc: Add viperboard adc driver")
> > Signed-off-by: Salah Triki <salah.triki@gmail.com>
>
> Nitpick, but I would add adc into the patch title ("iio: adc: viperboard: ...").
>
[snip]
>
> Code-wise LGTM.
>
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
>

Agree with Joshua here. Should add adc to subject but lgtm.

Reviewed-by: Maxwell Doose <m32285159@gmail.com>

best regards,
max

(p.s., might be a good idea to send a patch for this file replacing
all of the mutex_lock()s and unlock()s with guard()())

> --
> Kind regards
>
> CJD
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw
  2026-05-05 21:17 [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw Salah Triki
  2026-05-05 22:05 ` Joshua Crofts
@ 2026-05-06  8:35 ` Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-05-06  8:35 UTC (permalink / raw)
  To: Salah Triki
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

On Tue, May 05, 2026 at 10:17:50PM +0100, Salah Triki wrote:
> The driver proceeds to the reception phase even if the preceding
> transmission fails.
> 
> This uses a goto error label for an early bail out and ensures the mutex is
> properly unlocked in case of failure.

...

>  		if (ret != sizeof(struct vprbrd_adc_msg)) {
>  			dev_err(&iio_dev->dev, "usb send error on adc read\n");
>  			error = -EREMOTEIO;
> +			mutex_unlock(&vb->lock);
> +			goto error;

Printing message can be out from critical section (yeah, the guard()() or
whatever change may do it differently, but it's unrelated to this patch).

>  		}

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-06  8:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 21:17 [PATCH] iio: viperboard: Fix error handling in vprbrd_iio_read_raw Salah Triki
2026-05-05 22:05 ` Joshua Crofts
2026-05-05 22:19   ` Maxwell Doose
2026-05-06  8:35 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox