All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client
@ 2022-05-24  7:45 Miaoqian Lin
  2022-06-03 15:29 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-05-24  7:45 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Alexandru Ardelean, linux-iio, linux-kernel
  Cc: linmq006

of_parse_phandle() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
Add missing of_node_put() to avoid refcount leak.

Fixes: ef04070692a2 ("iio: adc: adi-axi-adc: add support for AXI ADC IP core")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/iio/adc/adi-axi-adc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index a73e3c2d212f..a9e655e69eaa 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -322,16 +322,19 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev)
 
 		if (!try_module_get(cl->dev->driver->owner)) {
 			mutex_unlock(&registered_clients_lock);
+			of_node_put(cln);
 			return ERR_PTR(-ENODEV);
 		}
 
 		get_device(cl->dev);
 		cl->info = info;
 		mutex_unlock(&registered_clients_lock);
+		of_node_put(cln);
 		return cl;
 	}
 
 	mutex_unlock(&registered_clients_lock);
+	of_node_put(cln);
 
 	return ERR_PTR(-EPROBE_DEFER);
 }
-- 
2.25.1


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

* Re: [PATCH] iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client
  2022-05-24  7:45 [PATCH] iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client Miaoqian Lin
@ 2022-06-03 15:29 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-06-03 15:29 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Lars-Peter Clausen, Michael Hennerich, Alexandru Ardelean,
	linux-iio, linux-kernel

On Tue, 24 May 2022 11:45:17 +0400
Miaoqian Lin <linmq006@gmail.com> wrote:

> of_parse_phandle() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when not need anymore.
> Add missing of_node_put() to avoid refcount leak.
> 
> Fixes: ef04070692a2 ("iio: adc: adi-axi-adc: add support for AXI ADC IP core")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Looks 'obviously correct to me' so applied to the fixes togreg branch of iio.git
and marked for stable.

Great if anyone more familiar with this driver than me has a chance
to take a quick look though.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/adi-axi-adc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
> index a73e3c2d212f..a9e655e69eaa 100644
> --- a/drivers/iio/adc/adi-axi-adc.c
> +++ b/drivers/iio/adc/adi-axi-adc.c
> @@ -322,16 +322,19 @@ static struct adi_axi_adc_client *adi_axi_adc_attach_client(struct device *dev)
>  
>  		if (!try_module_get(cl->dev->driver->owner)) {
>  			mutex_unlock(&registered_clients_lock);
> +			of_node_put(cln);
>  			return ERR_PTR(-ENODEV);
>  		}
>  
>  		get_device(cl->dev);
>  		cl->info = info;
>  		mutex_unlock(&registered_clients_lock);
> +		of_node_put(cln);
>  		return cl;
>  	}
>  
>  	mutex_unlock(&registered_clients_lock);
> +	of_node_put(cln);
>  
>  	return ERR_PTR(-EPROBE_DEFER);
>  }


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

end of thread, other threads:[~2022-06-03 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24  7:45 [PATCH] iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client Miaoqian Lin
2022-06-03 15:29 ` Jonathan Cameron

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.