linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] iio: adc: stm32: fix null pointer on defer_probe error
@ 2021-11-22 14:38 Olivier Moysan
  2021-11-22 14:41 ` Ahmad Fatoum
  0 siblings, 1 reply; 4+ messages in thread
From: Olivier Moysan @ 2021-11-22 14:38 UTC (permalink / raw)
  To: Ahmad Fatoum, Alexandre Torgue, Fabrice Gasnier,
	Jonathan Cameron, Lars-Peter Clausen, Maxime Coquelin,
	Olivier Moysan, Wan Jiabing, Xu Wang
  Cc: linux-arm-kernel, linux-iio, linux-kernel, linux-stm32

dev_err_probe() calls __device_set_deferred_probe_reason()
on -EPROBE_DEFER error. If device pointer to driver core
private structure is not initialized, an null pointer error occurs.
This pointer is set on iio_device_register() call for iio device.

dev_err_probe() must be called with the device which is probing.
Replace iio device by its parent device.

Fixes: 0e346b2cfa85 ("iio: adc: stm32-adc: add vrefint calibration support")

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
---
Changes in v2:
- Use parent device from indio_dev instead of private structure
---
 drivers/iio/adc/stm32-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 7f1fb36c747c..341afdd342cc 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -1986,7 +1986,7 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n
 			/* Get calibration data for vrefint channel */
 			ret = nvmem_cell_read_u16(&indio_dev->dev, "vrefint", &vrefint);
 			if (ret && ret != -ENOENT) {
-				return dev_err_probe(&indio_dev->dev, ret,
+				return dev_err_probe(indio_dev->dev.parent, ret,
 						     "nvmem access error\n");
 			}
 			if (ret == -ENOENT)
-- 
2.17.1


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

* Re: [PATCH v2] iio: adc: stm32: fix null pointer on defer_probe error
  2021-11-22 14:38 [PATCH v2] iio: adc: stm32: fix null pointer on defer_probe error Olivier Moysan
@ 2021-11-22 14:41 ` Ahmad Fatoum
  2021-11-22 14:45   ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2021-11-22 14:41 UTC (permalink / raw)
  To: Olivier Moysan, Alexandre Torgue, Fabrice Gasnier,
	Jonathan Cameron, Lars-Peter Clausen, Maxime Coquelin,
	Wan Jiabing, Xu Wang
  Cc: linux-arm-kernel, linux-iio, linux-kernel, linux-stm32

On 22.11.21 15:38, Olivier Moysan wrote:
> dev_err_probe() calls __device_set_deferred_probe_reason()
> on -EPROBE_DEFER error. If device pointer to driver core
> private structure is not initialized, an null pointer error occurs.
> This pointer is set on iio_device_register() call for iio device.
> 
> dev_err_probe() must be called with the device which is probing.
> Replace iio device by its parent device.
> 
> Fixes: 0e346b2cfa85 ("iio: adc: stm32-adc: add vrefint calibration support")
> 
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
> Changes in v2:
> - Use parent device from indio_dev instead of private structure
> ---
>  drivers/iio/adc/stm32-adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index 7f1fb36c747c..341afdd342cc 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -1986,7 +1986,7 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n
>  			/* Get calibration data for vrefint channel */
>  			ret = nvmem_cell_read_u16(&indio_dev->dev, "vrefint", &vrefint);
>  			if (ret && ret != -ENOENT) {
> -				return dev_err_probe(&indio_dev->dev, ret,
> +				return dev_err_probe(indio_dev->dev.parent, ret,
>  						     "nvmem access error\n");
>  			}
>  			if (ret == -ENOENT)
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH v2] iio: adc: stm32: fix null pointer on defer_probe error
  2021-11-22 14:41 ` Ahmad Fatoum
@ 2021-11-22 14:45   ` Jonathan Cameron
  2021-11-27 16:10     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2021-11-22 14:45 UTC (permalink / raw)
  To: Ahmad Fatoum
  Cc: Olivier Moysan, Alexandre Torgue, Fabrice Gasnier,
	Jonathan Cameron, Lars-Peter Clausen, Maxime Coquelin,
	Wan Jiabing, Xu Wang, linux-arm-kernel, linux-iio, linux-kernel,
	linux-stm32

On Mon, 22 Nov 2021 15:41:10 +0100
Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:

> On 22.11.21 15:38, Olivier Moysan wrote:
> > dev_err_probe() calls __device_set_deferred_probe_reason()
> > on -EPROBE_DEFER error. If device pointer to driver core
> > private structure is not initialized, an null pointer error occurs.
> > This pointer is set on iio_device_register() call for iio device.
> > 
> > dev_err_probe() must be called with the device which is probing.
> > Replace iio device by its parent device.
> > 
> > Fixes: 0e346b2cfa85 ("iio: adc: stm32-adc: add vrefint calibration support")
> > 

I'll fix it when applying, but no blank line between Fixes tag and the others.

> > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>  
> 
> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> 
> > ---
> > Changes in v2:
> > - Use parent device from indio_dev instead of private structure
> > ---
> >  drivers/iio/adc/stm32-adc.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> > index 7f1fb36c747c..341afdd342cc 100644
> > --- a/drivers/iio/adc/stm32-adc.c
> > +++ b/drivers/iio/adc/stm32-adc.c
> > @@ -1986,7 +1986,7 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n
> >  			/* Get calibration data for vrefint channel */
> >  			ret = nvmem_cell_read_u16(&indio_dev->dev, "vrefint", &vrefint);
> >  			if (ret && ret != -ENOENT) {
> > -				return dev_err_probe(&indio_dev->dev, ret,
> > +				return dev_err_probe(indio_dev->dev.parent, ret,
> >  						     "nvmem access error\n");
> >  			}
> >  			if (ret == -ENOENT)
> >   
> 
> 


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

* Re: [PATCH v2] iio: adc: stm32: fix null pointer on defer_probe error
  2021-11-22 14:45   ` Jonathan Cameron
@ 2021-11-27 16:10     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2021-11-27 16:10 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Ahmad Fatoum, Olivier Moysan, Alexandre Torgue, Fabrice Gasnier,
	Lars-Peter Clausen, Maxime Coquelin, Wan Jiabing, Xu Wang,
	linux-arm-kernel, linux-iio, linux-kernel, linux-stm32

On Mon, 22 Nov 2021 14:45:01 +0000
Jonathan Cameron <Jonathan.Cameron@Huawei.com> wrote:

> On Mon, 22 Nov 2021 15:41:10 +0100
> Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
> 
> > On 22.11.21 15:38, Olivier Moysan wrote:  
> > > dev_err_probe() calls __device_set_deferred_probe_reason()
> > > on -EPROBE_DEFER error. If device pointer to driver core
> > > private structure is not initialized, an null pointer error occurs.
> > > This pointer is set on iio_device_register() call for iio device.
> > > 
> > > dev_err_probe() must be called with the device which is probing.
> > > Replace iio device by its parent device.
> > > 
> > > Fixes: 0e346b2cfa85 ("iio: adc: stm32-adc: add vrefint calibration support")
> > >   
> 
> I'll fix it when applying, but no blank line between Fixes tag and the others.
Applied to the fixes-togreg branch of iio.git.

I'll probably do a pull request later this week,

Jonathan

> 
> > > Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>    
> > 
> > Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> >   
> > > ---
> > > Changes in v2:
> > > - Use parent device from indio_dev instead of private structure
> > > ---
> > >  drivers/iio/adc/stm32-adc.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> > > index 7f1fb36c747c..341afdd342cc 100644
> > > --- a/drivers/iio/adc/stm32-adc.c
> > > +++ b/drivers/iio/adc/stm32-adc.c
> > > @@ -1986,7 +1986,7 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n
> > >  			/* Get calibration data for vrefint channel */
> > >  			ret = nvmem_cell_read_u16(&indio_dev->dev, "vrefint", &vrefint);
> > >  			if (ret && ret != -ENOENT) {
> > > -				return dev_err_probe(&indio_dev->dev, ret,
> > > +				return dev_err_probe(indio_dev->dev.parent, ret,
> > >  						     "nvmem access error\n");
> > >  			}
> > >  			if (ret == -ENOENT)
> > >     
> > 
> >   
> 


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

end of thread, other threads:[~2021-11-27 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 14:38 [PATCH v2] iio: adc: stm32: fix null pointer on defer_probe error Olivier Moysan
2021-11-22 14:41 ` Ahmad Fatoum
2021-11-22 14:45   ` Jonathan Cameron
2021-11-27 16:10     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).