When trying out 6.13 cocci, some bugs were found.
The fixes without using cleanup.h should be backported. The last two patches make use of cleanup.h to avoid this kind of errors in the future.
Signed-off-by: Ricardo Ribalda ribalda@chromium.org --- Ricardo Ribalda (4): media: nuvoton: Fix reference handling of ece_pdev media: nuvoton: Fix reference handling of ece_node media: nuvoton: Use cleanup.h macros for device_node media: nuvoton: Use cleanup.h macros for put_device
drivers/media/platform/nuvoton/npcm-video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- base-commit: c4b7779abc6633677e6edb79e2809f4f61fde157 change-id: 20250121-nuvoton-fe870cbeffb6
Best regards,
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.
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 --- 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);
Make sure all the code paths call of_node_put().
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 --- drivers/media/platform/nuvoton/npcm-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c index 7b4c23dbe709..f6cba17a7924 100644 --- a/drivers/media/platform/nuvoton/npcm-video.c +++ b/drivers/media/platform/nuvoton/npcm-video.c @@ -1665,11 +1665,11 @@ static int npcm_video_ece_init(struct npcm_video *video) dev_info(dev, "Support HEXTILE pixel format\n");
ece_pdev = of_find_device_by_node(ece_node); + of_node_put(ece_node); if (!ece_pdev) { dev_err(dev, "Failed to find ECE device\n"); return -ENODEV; } - of_node_put(ece_node);
regs = devm_platform_ioremap_resource(ece_pdev, 0); if (IS_ERR(regs)) { @@ -1692,6 +1692,8 @@ static int npcm_video_ece_init(struct npcm_video *video) dev_err(dev, "Failed to get ECE reset control in DTS\n"); return PTR_ERR(video->ece.reset); } + } else { + of_node_put(ece_node); }
return 0;
linux-stable-mirror@lists.linaro.org