All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
@ 2018-03-08  9:31 ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2018-03-08  9:31 UTC (permalink / raw)
  To: Jonathan Cameron, Martin Blumenstingl
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Carlo Caione, Kevin Hilman, Rob Herring, Paolo Cretaro,
	Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen, linux-iio,
	kernel-janitors

The meson_sar_adc_lock() function is not supposed to hold the
"indio_dev->mlock" on the error path.

Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 29fa7736d80c..ede955d9b2a4 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -462,8 +462,10 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
 			regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val);
 		} while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--);
 
-		if (timeout < 0)
+		if (timeout < 0) {
+			mutex_unlock(&indio_dev->mlock);
 			return -ETIMEDOUT;
+		}
 	}
 
 	return 0;

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

* [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
@ 2018-03-08  9:31 ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2018-03-08  9:31 UTC (permalink / raw)
  To: Jonathan Cameron, Martin Blumenstingl
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Carlo Caione, Kevin Hilman, Rob Herring, Paolo Cretaro,
	Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen, linux-iio,
	kernel-janitors

The meson_sar_adc_lock() function is not supposed to hold the
"indio_dev->mlock" on the error path.

Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 29fa7736d80c..ede955d9b2a4 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -462,8 +462,10 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
 			regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val);
 		} while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--);
 
-		if (timeout < 0)
+		if (timeout < 0) {
+			mutex_unlock(&indio_dev->mlock);
 			return -ETIMEDOUT;
+		}
 	}
 
 	return 0;

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

* Re: [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
  2018-03-08  9:31 ` Dan Carpenter
  (?)
@ 2018-03-10 15:15 ` Jonathan Cameron
  -1 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2018-03-10 15:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Martin Blumenstingl, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Carlo Caione, Kevin Hilman, Rob Herring,
	Paolo Cretaro, Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen,
	linux-iio, kernel-janitors

On Thu, 8 Mar 2018 12:31:53 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The meson_sar_adc_lock() function is not supposed to hold the
> "indio_dev->mlock" on the error path.
> 
> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks

Jonathan

> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 29fa7736d80c..ede955d9b2a4 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -462,8 +462,10 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev)
>  			regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val);
>  		} while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--);
>  
> -		if (timeout < 0)
> +		if (timeout < 0) {
> +			mutex_unlock(&indio_dev->mlock);
>  			return -ETIMEDOUT;
> +		}
>  	}
>  
>  	return 0;


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

* Re: [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
  2018-03-08  9:31 ` Dan Carpenter
@ 2018-03-12 20:43   ` Martin Blumenstingl
  -1 siblings, 0 replies; 7+ messages in thread
From: Martin Blumenstingl @ 2018-03-12 20:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Carlo Caione, Kevin Hilman, Rob Herring,
	Paolo Cretaro, Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen,
	linux-iio, kernel-janitors

Hi Dan,

On Thu, Mar 8, 2018 at 10:31 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The meson_sar_adc_lock() function is not supposed to hold the
> "indio_dev->mlock" on the error path.
>
> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>

(even if I might be too late already since Jonathan already applied this patch)

thank you for finding and fixing this!
out of curiosity: did you find this with some tool (sparse?) or by
looking at the code?


Regards
Martin

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

* Re: [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
@ 2018-03-12 20:43   ` Martin Blumenstingl
  0 siblings, 0 replies; 7+ messages in thread
From: Martin Blumenstingl @ 2018-03-12 20:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Carlo Caione, Kevin Hilman, Rob Herring,
	Paolo Cretaro, Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen,
	linux-iio, kernel-janitors

Hi Dan,

On Thu, Mar 8, 2018 at 10:31 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The meson_sar_adc_lock() function is not supposed to hold the
> "indio_dev->mlock" on the error path.
>
> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>

(even if I might be too late already since Jonathan already applied this patch)

thank you for finding and fixing this!
out of curiosity: did you find this with some tool (sparse?) or by
looking at the code?


Regards
Martin

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

* Re: [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
  2018-03-12 20:43   ` Martin Blumenstingl
@ 2018-03-13  8:16     ` Dan Carpenter
  -1 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2018-03-13  8:16 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Carlo Caione, Kevin Hilman, Rob Herring,
	Paolo Cretaro, Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen,
	linux-iio, kernel-janitors

On Mon, Mar 12, 2018 at 09:43:19PM +0100, Martin Blumenstingl wrote:
> Hi Dan,
> 
> On Thu, Mar 8, 2018 at 10:31 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > The meson_sar_adc_lock() function is not supposed to hold the
> > "indio_dev->mlock" on the error path.
> >
> > Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>
> 
> (even if I might be too late already since Jonathan already applied this patch)
> 
> thank you for finding and fixing this!
> out of curiosity: did you find this with some tool (sparse?) or by
> looking at the code?
> 

This was some Smatch stuff that I haven't pushed.  I re-wrote the
locking check to use cross function analysis, and it actually warns
about the callers not meson_sar_adc_lock().  That code works ok
basically for locks but it generates a ton of false positives about
double unlocks so I haven't pushed it.

regards,
dan carpenter


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

* Re: [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock()
@ 2018-03-13  8:16     ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2018-03-13  8:16 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Carlo Caione, Kevin Hilman, Rob Herring,
	Paolo Cretaro, Heiner Kallweit, Gustavo A. R. Silva, Xingyu Chen,
	linux-iio, kernel-janitors

On Mon, Mar 12, 2018 at 09:43:19PM +0100, Martin Blumenstingl wrote:
> Hi Dan,
> 
> On Thu, Mar 8, 2018 at 10:31 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > The meson_sar_adc_lock() function is not supposed to hold the
> > "indio_dev->mlock" on the error path.
> >
> > Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Martin Blumenstingl<martin.blumenstingl@googlemail.com>
> 
> (even if I might be too late already since Jonathan already applied this patch)
> 
> thank you for finding and fixing this!
> out of curiosity: did you find this with some tool (sparse?) or by
> looking at the code?
> 

This was some Smatch stuff that I haven't pushed.  I re-wrote the
locking check to use cross function analysis, and it actually warns
about the callers not meson_sar_adc_lock().  That code works ok
basically for locks but it generates a ton of false positives about
double unlocks so I haven't pushed it.

regards,
dan carpenter

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

end of thread, other threads:[~2018-03-13  8:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08  9:31 [PATCH] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock() Dan Carpenter
2018-03-08  9:31 ` Dan Carpenter
2018-03-10 15:15 ` Jonathan Cameron
2018-03-12 20:43 ` Martin Blumenstingl
2018-03-12 20:43   ` Martin Blumenstingl
2018-03-13  8:16   ` Dan Carpenter
2018-03-13  8:16     ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.