diff mbox series

[1/5] media: i2c: max9286: Put of node on error

Message ID 20200316202757.529740-2-jacopo+renesas@jmondi.org (mailing list archive)
State New, archived
Headers show
Series media: i2c: max9286: Add configuration properties | expand

Commit Message

Jacopo Mondi March 16, 2020, 8:27 p.m. UTC
Put the device of node in case of dt parsing error.

Fixes: 9eed4185c7a0 ("media: i2c: Add MAX9286 driver")
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/max9286.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Kieran Bingham March 18, 2020, 9:32 a.m. UTC | #1
Hi Jacopo

On 16/03/2020 20:27, Jacopo Mondi wrote:
> Put the device of node in case of dt parsing error.
> 

Ooops, it does look like this probably leaks - but isn't it also leaking
in other code paths in this function too?

If we fix here, we should fix all leaks of this usage. (and perhaps
identify if there are leaks of other refcnts too ;-S )


> Fixes: 9eed4185c7a0 ("media: i2c: Add MAX9286 driver")
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/media/i2c/max9286.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index a20829297ef6..06edd8bd3e82 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -1046,6 +1046,7 @@ static int max9286_parse_dt(struct max9286_priv *priv)
>  	i2c_mux = of_find_node_by_name(dev->of_node, "i2c-mux");
>  	if (!i2c_mux) {
>  		dev_err(dev, "Failed to find i2c-mux node\n");
> +		of_node_put(dev->of_node);
>  		return -EINVAL;
>  	}
>  
>
Jacopo Mondi March 18, 2020, 2:06 p.m. UTC | #2
Hi Kieran,

On Wed, Mar 18, 2020 at 09:32:45AM +0000, Kieran Bingham wrote:
> Hi Jacopo
>
> On 16/03/2020 20:27, Jacopo Mondi wrote:
> > Put the device of node in case of dt parsing error.
> >
>
> Ooops, it does look like this probably leaks - but isn't it also leaking
> in other code paths in this function too?

I checked and got confused by the very last
        of_node_put(node);

which should be coupled with and additional
        of_node_put(dev->of_node);

I don't see any additional leak, am I mistaken ?

>
> If we fix here, we should fix all leaks of this usage. (and perhaps
> identify if there are leaks of other refcnts too ;-S )
>
>
> > Fixes: 9eed4185c7a0 ("media: i2c: Add MAX9286 driver")
> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > ---
> >  drivers/media/i2c/max9286.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> > index a20829297ef6..06edd8bd3e82 100644
> > --- a/drivers/media/i2c/max9286.c
> > +++ b/drivers/media/i2c/max9286.c
> > @@ -1046,6 +1046,7 @@ static int max9286_parse_dt(struct max9286_priv *priv)
> >  	i2c_mux = of_find_node_by_name(dev->of_node, "i2c-mux");
> >  	if (!i2c_mux) {
> >  		dev_err(dev, "Failed to find i2c-mux node\n");
> > +		of_node_put(dev->of_node);
> >  		return -EINVAL;
> >  	}
> >
> >
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index a20829297ef6..06edd8bd3e82 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -1046,6 +1046,7 @@  static int max9286_parse_dt(struct max9286_priv *priv)
 	i2c_mux = of_find_node_by_name(dev->of_node, "i2c-mux");
 	if (!i2c_mux) {
 		dev_err(dev, "Failed to find i2c-mux node\n");
+		of_node_put(dev->of_node);
 		return -EINVAL;
 	}