@@ -99,12 +99,12 @@ static u32 __init imx8mq_soc_revision(void)
static void __init imx8mm_soc_uid(void)
{
void __iomem *ocotp_base;
- struct device_node *np;
+ struct device_node *np __free(device_node) =
+ of_find_compatible_node(NULL, NULL, "fsl,imx8mm-ocotp");
struct clk *clk;
u32 offset = of_machine_is_compatible("fsl,imx8mp") ?
IMX8MP_OCOTP_UID_OFFSET : 0;
- np = of_find_compatible_node(NULL, NULL, "fsl,imx8mm-ocotp");
if (!np)
return;
@@ -125,7 +125,6 @@ static void __init imx8mm_soc_uid(void)
clk_disable_unprepare(clk);
clk_put(clk);
iounmap(ocotp_base);
- of_node_put(np);
}
static u32 __init imx8mm_soc_revision(void)
An error path was introduced without including the required call to of_node_put() to decrement the node's refcount and avoid leaking memory. If the call to of_clk_get_by_name() for 'clk' fails, the probe returns without decrementing the refcount. Use the automatic cleanup facility to fix the bug and protect the code against new error paths where the call to of_node_put() might be missing again. Cc: stable@vger.kernel.org Fixes: 836fb30949d9 ("soc: imx8m: Enable OCOTP clock before reading the register") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- drivers/soc/imx/soc-imx8m.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- base-commit: d61a00525464bfc5fe92c6ad713350988e492b88 change-id: 20241013-soc-imx8m-of_node_put-526a1c8ab540 Best regards,