]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: renesas: rcar_drif: fix device node reference leak in rcar_drif_bond_enabled
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 3 Sep 2025 13:37:29 +0000 (21:37 +0800)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 3 Nov 2025 14:58:41 +0000 (15:58 +0100)
The function calls of_parse_phandle() which returns
a device node with an incremented reference count. When the bonded device
is not available, the function
returns NULL without releasing the reference, causing a reference leak.

Add of_node_put(np) to release the device node reference.
The of_node_put function handles NULL pointers.

Found through static analysis by reviewing the doc of of_parse_phandle()
and cross-checking its usage patterns across the codebase.

Fixes: 7625ee981af1 ("[media] media: platform: rcar_drif: Add DRIF support")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/renesas/rcar_drif.c

index 11bf47fb8266dc45df40cac003f039582251b945..0844934f7aa68b3b934c444340cad9084d415659 100644 (file)
@@ -1246,6 +1246,7 @@ static struct device_node *rcar_drif_bond_enabled(struct platform_device *p)
        if (np && of_device_is_available(np))
                return np;
 
+       of_node_put(np);
        return NULL;
 }