LinuxTV Patchwork [1/9] davinci-vpif: Fix endpoint refcounting

login
register
mail settings
Submitter Sakari Ailus
Date April 5, 2019, 9:41 a.m.
Message ID <20190405094127.18975-3-sakari.ailus@linux.intel.com>
Download mbox | patch
Permalink /patch/55474/
State New
Headers show

Comments

Sakari Ailus - April 5, 2019, 9:41 a.m.
This patch addresses two problems with endpoint refcounting in parsing
davinci-vpif endpoints:

- put endpoints on error and

- do not dereference endpoints after they have been put.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/platform/davinci/vpif_capture.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Ian Arkver - April 5, 2019, 11:30 a.m.
Hi Sakari,

My mail client at least is showing two versions of patch [1/9] with 
different commit messages but (I think) the same content.

Regards,
Ian

On 05/04/2019 10:41, Sakari Ailus wrote:
> This patch addresses two problems with endpoint refcounting in parsing
> davinci-vpif endpoints:
> 
> - put endpoints on error and
> 
> - do not dereference endpoints after they have been put.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>   drivers/media/platform/davinci/vpif_capture.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index b5aacb0fb96b..72bdb3c10962 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1555,7 +1555,6 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>   		if (!rem) {
>   			dev_dbg(&pdev->dev, "Remote device at %pOF not found\n",
>   				endpoint);
> -			of_node_put(endpoint);
>   			goto done;
>   		}
>   
> @@ -1567,7 +1566,6 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>   					    GFP_KERNEL);
>   		if (!chan->inputs) {
>   			of_node_put(rem);
> -			of_node_put(endpoint);
>   			goto err_cleanup;
>   		}
>   
> @@ -1578,7 +1576,6 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>   
>   		err = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
>   						 &bus_cfg);
> -		of_node_put(endpoint);
>   		if (err) {
>   			dev_err(&pdev->dev, "Could not parse the endpoint\n");
>   			of_node_put(rem);
> @@ -1609,6 +1606,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>   	}
>   
>   done:
> +	of_node_put(endpoint);
>   	pdata->asd_sizes[0] = i;
>   	pdata->subdev_count = i;
>   	pdata->card_name = "DA850/OMAP-L138 Video Capture";
> @@ -1616,6 +1614,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)
>   	return pdata;
>   
>   err_cleanup:
> +	of_node_put(endpoint);
>   	v4l2_async_notifier_cleanup(&vpif_obj.notifier);
>   
>   	return NULL;
>
Sakari Ailus - April 5, 2019, 11:34 a.m.
Hi Ian,

On Fri, Apr 05, 2019 at 12:30:07PM +0100, Ian Arkver wrote:
> Hi Sakari,
> 
> My mail client at least is showing two versions of patch [1/9] with
> different commit messages but (I think) the same content.

Thanks for spotting this. I used the same output directory for git
format-patch after changing the commit message. Oh well.

The other one is what I intended to send; please ignore this one.

Patch

diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index b5aacb0fb96b..72bdb3c10962 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1555,7 +1555,6 @@  vpif_capture_get_pdata(struct platform_device *pdev)
 		if (!rem) {
 			dev_dbg(&pdev->dev, "Remote device at %pOF not found\n",
 				endpoint);
-			of_node_put(endpoint);
 			goto done;
 		}
 
@@ -1567,7 +1566,6 @@  vpif_capture_get_pdata(struct platform_device *pdev)
 					    GFP_KERNEL);
 		if (!chan->inputs) {
 			of_node_put(rem);
-			of_node_put(endpoint);
 			goto err_cleanup;
 		}
 
@@ -1578,7 +1576,6 @@  vpif_capture_get_pdata(struct platform_device *pdev)
 
 		err = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
 						 &bus_cfg);
-		of_node_put(endpoint);
 		if (err) {
 			dev_err(&pdev->dev, "Could not parse the endpoint\n");
 			of_node_put(rem);
@@ -1609,6 +1606,7 @@  vpif_capture_get_pdata(struct platform_device *pdev)
 	}
 
 done:
+	of_node_put(endpoint);
 	pdata->asd_sizes[0] = i;
 	pdata->subdev_count = i;
 	pdata->card_name = "DA850/OMAP-L138 Video Capture";
@@ -1616,6 +1614,7 @@  vpif_capture_get_pdata(struct platform_device *pdev)
 	return pdata;
 
 err_cleanup:
+	of_node_put(endpoint);
 	v4l2_async_notifier_cleanup(&vpif_obj.notifier);
 
 	return NULL;

Privacy Policy