Current code leaves the device's wakeup enabled in the error path of .probe(), which results in a memory leak. Call device_init_wakeup() as the last step in the .probe() to avoid this leak. This bug was found by an experimental static analysis tool that I am developing. Fixes: 32a4a4ebf768 ("rtc: bd70528: Initial support for ROHM bd70528 RTC") Signed-off-by: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx> --- Changes in V2: - Move the device_init_wakeup() to the last step of the .probe() to make the cleanup simpler. --- drivers/rtc/rtc-bd70528.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-bd70528.c b/drivers/rtc/rtc-bd70528.c index 954ac4ef53e8..d5cc4993f918 100644 --- a/drivers/rtc/rtc-bd70528.c +++ b/drivers/rtc/rtc-bd70528.c @@ -312,9 +312,6 @@ static int bd70528_probe(struct platform_device *pdev) } } - device_set_wakeup_capable(&pdev->dev, true); - device_wakeup_enable(&pdev->dev); - rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc)) { dev_err(&pdev->dev, "RTC device creation failed\n"); @@ -331,7 +328,12 @@ static int bd70528_probe(struct platform_device *pdev) if (ret) return ret; - return devm_rtc_register_device(rtc); + ret = devm_rtc_register_device(rtc); + if (ret) + return ret; + + device_init_wakeup(&pdev->dev, true); + return 0; } static const struct platform_device_id bd718x7_rtc_id[] = { -- 2.34.1