Skip to content

Commit ba5e60c

Browse files
Peng Haoldesroches
authored andcommitted
arm/mach-at91/pm : fix possible object reference leak
of_find_device_by_node() takes a reference to the struct device when it finds a match via get_device. When returning error we should call put_device. Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn> Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent e7dfb6d commit ba5e60c

File tree

1 file changed

+4
-2
lines changed
  • arch/arm/mach-at91

1 file changed

+4
-2
lines changed

arch/arm/mach-at91/pm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,13 @@ static int __init at91_pm_backup_init(void)
591591

592592
np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
593593
if (!np)
594-
goto securam_fail;
594+
goto securam_fail_no_ref_dev;
595595

596596
pdev = of_find_device_by_node(np);
597597
of_node_put(np);
598598
if (!pdev) {
599599
pr_warn("%s: failed to find securam device!\n", __func__);
600-
goto securam_fail;
600+
goto securam_fail_no_ref_dev;
601601
}
602602

603603
sram_pool = gen_pool_get(&pdev->dev, NULL);
@@ -620,6 +620,8 @@ static int __init at91_pm_backup_init(void)
620620
return 0;
621621

622622
securam_fail:
623+
put_device(&pdev->dev);
624+
securam_fail_no_ref_dev:
623625
iounmap(pm_data.sfrbu);
624626
pm_data.sfrbu = NULL;
625627
return ret;

0 commit comments

Comments
 (0)