Re: [PATCH 1/4] media: nuvoton: Fix reference handling of ece_pdev

From: Markus Elfring
Date: Fri Feb 21 2025 - 08:02:19 EST



> > 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.

> 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? …

Not yet directly (for coccicheck scripts).
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/scripts/coccinelle/free/put_device.cocci?h=v6.14-rc3

I am unsure under which circumstances support can be added for the detection
of scope-based resource management also by the means of the semantic patch language.

Regards,
Markus