Skip to contentSkip to conversation

media: v4l2-async: Put fwnode after last access

PATCH In review Ezequiel Garcia 2 participants 3 messages Dec 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: v4l2-async: Put fwnode after last access

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")
---
 drivers/media/v4l2-core/v4l2-async.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +4 -2
index e3ab003a6c85..1303c9b83138 100644
@@ -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;
 
 	/*
Signature · 1 line
2.29.2
#1 lore raw

Hi Ezequiel,

Thank you for the patch.

Quoted 22 lines · 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")
---
 drivers/media/v4l2-core/v4l2-async.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +1 -0
index e3ab003a6c85..1303c9b83138 100644
@@ -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

drivers/media/v4l2-core/v4l2-async.c static bool match_fwnode(struct v4l2_async_notifier *notifier, · line 118

Quoted 7 lines
drivers/media/v4l2-core/v4l2-async.c +1 -2
@@ -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.

Quoted 5 lines
drivers/media/v4l2-core/v4l2-async.c +2 -0
+	fwnode_handle_put(dev_fwnode);
+	if (!match)
 		return false;
 
 	/*
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
Quoted 29 lines · Laurent Pinchart

Hi Ezequiel,

Thank you for the patch.

Quoted 24 lines · 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")

---
 drivers/media/v4l2-core/v4l2-async.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-async.c +1 -0
index e3ab003a6c85..1303c9b83138 100644
@@ -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

drivers/media/v4l2-core/v4l2-async.c +0 -0
@@ -113,9 +114,10 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
                 other_fwnode = sd->fwnode;
         }
Quoted 9 lines
Quoted 5 lines


-       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