lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e557b5a7-524b-56e0-0642-7f9c04c136f9@xs4all.nl>
Date:   Wed, 29 May 2019 10:56:48 +0200
From:   Hans Verkuil <hverkuil@...all.nl>
To:     Wen Yang <wen.yang99@....com.cn>, linux-kernel@...r.kernel.org
Cc:     wang.yi59@....com.cn, Patrice Chotard <patrice.chotard@...com>,
        Hyun Kwon <hyun.kwon@...inx.com>,
        Laurent Pinchart <laurent.pinchart@...asonboard.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Michal Simek <michal.simek@...inx.com>,
        linux-media@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 4/4] media: xilinx: fix leaked of_node references

On 5/6/19 9:05 AM, Wen Yang wrote:
> The call to of_get_child_by_name returns a node pointer with refcount
> incremented thus it must be explicitly decremented after the last
> usage.
> 
> Detected by coccinelle with the following warnings:
> drivers/media/platform/xilinx/xilinx-vipp.c:487:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 477, but without a corresponding object release within this function.
> drivers/media/platform/xilinx/xilinx-vipp.c:491:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 477, but without a corresponding object release within this function.
> 
> Signed-off-by: Wen Yang <wen.yang99@....com.cn>
> Cc: Patrice Chotard <patrice.chotard@...com>
> Cc: Hyun Kwon <hyun.kwon@...inx.com>
> Cc: Laurent Pinchart <laurent.pinchart@...asonboard.com>
> Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
> Cc: Michal Simek <michal.simek@...inx.com>
> Cc: linux-media@...r.kernel.org
> Cc: linux-arm-kernel@...ts.infradead.org
> Cc: linux-kernel@...r.kernel.org
> ---
>  drivers/media/platform/exynos4-is/fimc-is.c   | 1 +
>  drivers/media/platform/exynos4-is/media-dev.c | 1 +

Huh? This patch changes exynos4 as well, not just xilinx.

Please split this up into two patches, one for each driver.

>  drivers/media/platform/xilinx/xilinx-vipp.c   | 8 +++++---
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
> index 02da0b0..25df4c6 100644
> --- a/drivers/media/platform/exynos4-is/fimc-is.c
> +++ b/drivers/media/platform/exynos4-is/fimc-is.c
> @@ -809,6 +809,7 @@ static int fimc_is_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  
>  	is->pmu_regs = of_iomap(node, 0);
> +	of_node_put(node);
>  	if (!is->pmu_regs)
>  		return -ENOMEM;
>  
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index 463f2d8..a31dacf 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -450,6 +450,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
>  	else
>  		pd->fimc_bus_type = pd->sensor_bus_type;
>  
> +	of_node_put(np);
>  	if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) {
>  		of_node_put(rem);
>  		return -EINVAL;
> diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
> index edce040..307717c 100644
> --- a/drivers/media/platform/xilinx/xilinx-vipp.c
> +++ b/drivers/media/platform/xilinx/xilinx-vipp.c
> @@ -472,7 +472,7 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
>  {
>  	struct device_node *ports;
>  	struct device_node *port;
> -	int ret;
> +	int ret = 0;
>  
>  	ports = of_get_child_by_name(xdev->dev->of_node, "ports");
>  	if (ports == NULL) {
> @@ -484,11 +484,13 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev)
>  		ret = xvip_graph_dma_init_one(xdev, port);
>  		if (ret < 0) {
>  			of_node_put(port);
> -			return ret;
> +			goto out_put_node;

Just do a break here,

>  		}
>  	}
>  
> -	return 0;
> +out_put_node:

and drop this label.

> +	of_node_put(ports);
> +	return ret;
>  }
>  
>  static void xvip_graph_cleanup(struct xvip_composite_device *xdev)
> 

Regards,

	Hans

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ