Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: mediatek: mtk-svs: Call of_node_put(np) only once in svs_get_subsys_device()

An of_node_put(np) call was immediately used after a pointer check
for a of_find_device_by_node() call in this function implementation.
Thus call such a function only once instead directly before the check.

This issue was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/884f0a5d-e6d3-47dc-8a9e-201bb86b271f@web.de
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

authored by

Markus Elfring and committed by
AngeloGioacchino Del Regno
a1643ae9 d0fa55cc

+1 -3
+1 -3
drivers/soc/mediatek/mtk-svs.c
··· 2133 2133 } 2134 2134 2135 2135 pdev = of_find_device_by_node(np); 2136 + of_node_put(np); 2136 2137 if (!pdev) { 2137 - of_node_put(np); 2138 2138 dev_err(svsp->dev, "cannot find pdev by %s\n", node_name); 2139 2139 return ERR_PTR(-ENXIO); 2140 2140 } 2141 - 2142 - of_node_put(np); 2143 2141 2144 2142 return &pdev->dev; 2145 2143 }