]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: nuvoton: Fix reference handling of ece_pdev
authorRicardo Ribalda <ribalda@chromium.org>
Mon, 24 Feb 2025 07:03:55 +0000 (07:03 +0000)
committerHans Verkuil <hverkuil@xs4all.nl>
Tue, 25 Feb 2025 08:14:06 +0000 (09:14 +0100)
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.

Instead of manually calling put_device, use the __free macros.

Cc: stable@vger.kernel.org
Fixes: 46c15a4ff1f4 ("media: nuvoton: Add driver for NPCM video capture and encoding engine")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/nuvoton/npcm-video.c

index 0547f119c38f0de664f77de585d28d07c68cdd8b..7a9d8928ae4019ab50467f8a1ec23f977de38230 100644 (file)
@@ -1669,6 +1669,7 @@ static int npcm_video_ece_init(struct npcm_video *video)
                        dev_err(dev, "Failed to find ECE device\n");
                        return -ENODEV;
                }
+               struct device *ece_dev __free(put_device) = &ece_pdev->dev;
 
                regs = devm_platform_ioremap_resource(ece_pdev, 0);
                if (IS_ERR(regs)) {
@@ -1683,7 +1684,7 @@ static int npcm_video_ece_init(struct npcm_video *video)
                        return PTR_ERR(video->ece.regmap);
                }
 
-               video->ece.reset = devm_reset_control_get(&ece_pdev->dev, NULL);
+               video->ece.reset = devm_reset_control_get(ece_dev, NULL);
                if (IS_ERR(video->ece.reset)) {
                        dev_err(dev, "Failed to get ECE reset control in DTS\n");
                        return PTR_ERR(video->ece.reset);