diff mbox series

[1/2] iio: adc: adi-axi-adc: Fix object reference counting

Message ID 20200701120442.258-1-nuno.sa@analog.com (mailing list archive)
State New, archived
Headers show
Series [1/2] iio: adc: adi-axi-adc: Fix object reference counting | expand

Commit Message

Nuno Sa July 1, 2020, 12:04 p.m. UTC
When looking for a registered client to attach with, the wrong reference
counters are being grabbed. The idea is to increment the module and device
counters of the client device and not the counters of the axi device being
probed.

Fixes: ef04070692a2 (iio: adc: adi-axi-adc: add support for AXI ADC IP core)

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/adi-axi-adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alexandru Ardelean July 1, 2020, 2:07 p.m. UTC | #1
On Wed, 2020-07-01 at 14:04 +0200, Nuno Sá wrote:
> [External]
> 
> When looking for a registered client to attach with, the wrong reference
> counters are being grabbed. The idea is to increment the module and
> device
> counters of the client device and not the counters of the axi device
> being
> probed.
> 

Yep.
Good catch here.

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

> Fixes: ef04070692a2 (iio: adc: adi-axi-adc: add support for AXI ADC IP
> core)
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/adc/adi-axi-adc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-
> adc.c
> index 63d926e86798..86b6b65916ee 100644
> --- a/drivers/iio/adc/adi-axi-adc.c
> +++ b/drivers/iio/adc/adi-axi-adc.c
> @@ -332,12 +332,12 @@ static struct adi_axi_adc_client
> *adi_axi_adc_attach_client(struct device *dev)
>  		if (cl->dev->of_node != cln)
>  			continue;
>  
> -		if (!try_module_get(dev->driver->owner)) {
> +		if (!try_module_get(cl->dev->driver->owner)) {
>  			mutex_unlock(&registered_clients_lock);
>  			return ERR_PTR(-ENODEV);
>  		}
>  
> -		get_device(dev);
> +		get_device(cl->dev);
>  		cl->info = info;
>  		mutex_unlock(&registered_clients_lock);
>  		return cl;
Jonathan Cameron July 4, 2020, 4:06 p.m. UTC | #2
On Wed, 1 Jul 2020 14:07:05 +0000
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote:

> On Wed, 2020-07-01 at 14:04 +0200, Nuno Sá wrote:
> > [External]
> > 
> > When looking for a registered client to attach with, the wrong reference
> > counters are being grabbed. The idea is to increment the module and
> > device
> > counters of the client device and not the counters of the axi device
> > being
> > probed.
> >   
> 
> Yep.
> Good catch here.
> 
> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan

> 
> > Fixes: ef04070692a2 (iio: adc: adi-axi-adc: add support for AXI ADC IP
> > core)
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/adc/adi-axi-adc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-
> > adc.c
> > index 63d926e86798..86b6b65916ee 100644
> > --- a/drivers/iio/adc/adi-axi-adc.c
> > +++ b/drivers/iio/adc/adi-axi-adc.c
> > @@ -332,12 +332,12 @@ static struct adi_axi_adc_client
> > *adi_axi_adc_attach_client(struct device *dev)
> >  		if (cl->dev->of_node != cln)
> >  			continue;
> >  
> > -		if (!try_module_get(dev->driver->owner)) {
> > +		if (!try_module_get(cl->dev->driver->owner)) {
> >  			mutex_unlock(&registered_clients_lock);
> >  			return ERR_PTR(-ENODEV);
> >  		}
> >  
> > -		get_device(dev);
> > +		get_device(cl->dev);
> >  		cl->info = info;
> >  		mutex_unlock(&registered_clients_lock);
> >  		return cl;
diff mbox series

Patch

diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 63d926e86798..86b6b65916ee 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -332,12 +332,12 @@  static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev)
 		if (cl->dev->of_node != cln)
 			continue;
 
-		if (!try_module_get(dev->driver->owner)) {
+		if (!try_module_get(cl->dev->driver->owner)) {
 			mutex_unlock(&registered_clients_lock);
 			return ERR_PTR(-ENODEV);
 		}
 
-		get_device(dev);
+		get_device(cl->dev);
 		cl->info = info;
 		mutex_unlock(&registered_clients_lock);
 		return cl;