All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: v4l2-async: Put fwnode after last access
@ 2020-12-28 12:17 Ezequiel Garcia
  2020-12-28 13:16 ` Laurent Pinchart
  0 siblings, 1 reply; 3+ messages in thread
From: Ezequiel Garcia @ 2020-12-28 12:17 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: kernel, Hans Verkuil, Laurent Pinchart, Ezequiel Garcia

fwnode_handle_put() should be called after the fwnode
is last accessed. Fix it.

Fixes: b98158d837ef ("media: v4l2-async: Accept endpoints and devices for fwnode matching")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
---
 drivers/media/v4l2-core/v4l2-async.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index e3ab003a6c85..1303c9b83138 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -78,6 +78,7 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
 	bool asd_fwnode_is_ep;
 	bool sd_fwnode_is_ep;
 	struct device *dev;
+	bool match;
 
 	/*
 	 * Both the subdev and the async subdev can provide either an endpoint
@@ -113,9 +114,10 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
 		other_fwnode = sd->fwnode;
 	}
 
-	fwnode_handle_put(dev_fwnode);
+	match = (dev_fwnode == other_fwnode);
 
-	if (dev_fwnode != other_fwnode)
+	fwnode_handle_put(dev_fwnode);
+	if (!match)
 		return false;
 
 	/*
-- 
2.29.2


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

* Re: [PATCH] media: v4l2-async: Put fwnode after last access
  2020-12-28 12:17 [PATCH] media: v4l2-async: Put fwnode after last access Ezequiel Garcia
@ 2020-12-28 13:16 ` Laurent Pinchart
  2020-12-28 16:51   ` Ezequiel Garcia
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2020-12-28 13:16 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: linux-media, linux-kernel, kernel, Hans Verkuil, Laurent Pinchart

Hi Ezequiel,

Thank you for the patch.

On Mon, Dec 28, 2020 at 09:17:25AM -0300, Ezequiel Garcia wrote:
> fwnode_handle_put() should be called after the fwnode
> is last accessed. Fix it.
> 
> Fixes: b98158d837ef ("media: v4l2-async: Accept endpoints and devices for fwnode matching")
> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index e3ab003a6c85..1303c9b83138 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -78,6 +78,7 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
>  	bool asd_fwnode_is_ep;
>  	bool sd_fwnode_is_ep;
>  	struct device *dev;
> +	bool match;
>  
>  	/*
>  	 * Both the subdev and the async subdev can provide either an endpoint
> @@ -113,9 +114,10 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
>  		other_fwnode = sd->fwnode;
>  	}
>  
> -	fwnode_handle_put(dev_fwnode);
> +	match = (dev_fwnode == other_fwnode);
>  
> -	if (dev_fwnode != other_fwnode)

This only performs a pointer comparison, it doesn't access dev_fwnode. I
don't think the change is necessary.

> +	fwnode_handle_put(dev_fwnode);
> +	if (!match)
>  		return false;
>  
>  	/*

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] media: v4l2-async: Put fwnode after last access
  2020-12-28 13:16 ` Laurent Pinchart
@ 2020-12-28 16:51   ` Ezequiel Garcia
  0 siblings, 0 replies; 3+ messages in thread
From: Ezequiel Garcia @ 2020-12-28 16:51 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-media, linux-kernel, kernel, Hans Verkuil, Laurent Pinchart

On Mon, 2020-12-28 at 15:16 +0200, Laurent Pinchart wrote:
> Hi Ezequiel,
> 
> Thank you for the patch.
> 
> On Mon, Dec 28, 2020 at 09:17:25AM -0300, Ezequiel Garcia wrote:
> > fwnode_handle_put() should be called after the fwnode
> > is last accessed. Fix it.
> > 
> > Fixes: b98158d837ef ("media: v4l2-async: Accept endpoints and devices for fwnode matching")
> > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> > ---
> >  drivers/media/v4l2-core/v4l2-async.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> > index e3ab003a6c85..1303c9b83138 100644
> > --- a/drivers/media/v4l2-core/v4l2-async.c
> > +++ b/drivers/media/v4l2-core/v4l2-async.c
> > @@ -78,6 +78,7 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
> >         bool asd_fwnode_is_ep;
> >         bool sd_fwnode_is_ep;
> >         struct device *dev;
> > +       bool match;
> >  
> >         /*
> >          * Both the subdev and the async subdev can provide either an endpoint
> > @@ -113,9 +114,10 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
> >                 other_fwnode = sd->fwnode;
> >         }
> >  
> > -       fwnode_handle_put(dev_fwnode);
> > +       match = (dev_fwnode == other_fwnode);
> >  
> > -       if (dev_fwnode != other_fwnode)
> 
> This only performs a pointer comparison, it doesn't access dev_fwnode. I
> don't think the change is necessary.
> 

Ah, of course. I'm always confused by this.

Thanks,
Ezequiel


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

end of thread, other threads:[~2020-12-28 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 12:17 [PATCH] media: v4l2-async: Put fwnode after last access Ezequiel Garcia
2020-12-28 13:16 ` Laurent Pinchart
2020-12-28 16:51   ` Ezequiel Garcia

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.