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] [thread-next>] [day] [month] [year] [list]
Message-ID: <df5693d0-7747-4423-809e-ae081c9aae92@xs4all.nl>
Date: Fri, 21 Feb 2025 10:04:10 +0100
From: Hans Verkuil <hverkuil@...all.nl>
To: Ricardo Ribalda <ribalda@...omium.org>, Joseph Liu <kwliu@...oton.com>,
 Marvin Lin <kflin@...oton.com>, Mauro Carvalho Chehab <mchehab@...nel.org>,
 Philipp Zabel <p.zabel@...gutronix.de>
Cc: Marvin Lin <milkfafa@...il.com>, linux-media@...r.kernel.org,
 openbmc@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
 stable@...r.kernel.org
Subject: Re: [PATCH 1/4] media: nuvoton: Fix reference handling of ece_pdev

Hi Ricardo,

On 21/01/2025 22:14, Ricardo Ribalda wrote:
> When we obtain a reference to of a platform_device, we need to release
> it via put_device.
> 
> Found by cocci:
> ./platform/nuvoton/npcm-video.c:1677:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
> ./platform/nuvoton/npcm-video.c:1684:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
> ./platform/nuvoton/npcm-video.c:1690:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
> ./platform/nuvoton/npcm-video.c:1694:1-7: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.

This driver uses this construct:

                struct device *ece_dev __free(put_device) = &ece_pdev->dev;

to automatically call put_device. So this patch would 'put' the device twice.

Does cocci understand constructs like this? If I hadn't looked closely at the
code first, I would just have merged it.

Regards,

	Hans

> 
> Cc: stable@...r.kernel.org
> Fixes: 46c15a4ff1f4 ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
> Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
> ---
>  drivers/media/platform/nuvoton/npcm-video.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c
> index 024cd8ee1709..7b4c23dbe709 100644
> --- a/drivers/media/platform/nuvoton/npcm-video.c
> +++ b/drivers/media/platform/nuvoton/npcm-video.c
> @@ -1673,6 +1673,7 @@ static int npcm_video_ece_init(struct npcm_video *video)
>  
>  		regs = devm_platform_ioremap_resource(ece_pdev, 0);
>  		if (IS_ERR(regs)) {
> +			put_device(&ece_pdev->dev);
>  			dev_err(dev, "Failed to parse ECE reg in DTS\n");
>  			return PTR_ERR(regs);
>  		}
> @@ -1680,11 +1681,13 @@ static int npcm_video_ece_init(struct npcm_video *video)
>  		video->ece.regmap = devm_regmap_init_mmio(dev, regs,
>  							  &npcm_video_ece_regmap_cfg);
>  		if (IS_ERR(video->ece.regmap)) {
> +			put_device(&ece_pdev->dev);
>  			dev_err(dev, "Failed to initialize ECE regmap\n");
>  			return PTR_ERR(video->ece.regmap);
>  		}
>  
>  		video->ece.reset = devm_reset_control_get(&ece_pdev->dev, NULL);
> +		put_device(&ece_pdev->dev);
>  		if (IS_ERR(video->ece.reset)) {
>  			dev_err(dev, "Failed to get ECE reset control in DTS\n");
>  			return PTR_ERR(video->ece.reset);
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ