summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2020-04-03 12:04:37 +0100
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2020-04-03 13:38:24 +0200
commit1821b79d6a7d6973d1630e71380da8bb5e95f3a5 (patch)
treea15925b39a3d5edf37280b1eb5312804774cd372 /drivers/rtc
parent3edf29d9d585237c53f06e44227c4b36c8794222 (diff)
rtc: ds1307: check for failed memory allocation on wdt
Currently a failed memory allocation will lead to a null pointer dereference on point wdt. Fix this by checking for a failed allocation and just returning. Addresses-Coverity: ("Dereference null return") Fixes: fd90d48db037 ("rtc: ds1307: add support for watchdog timer on ds1388") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20200403110437.57420-1-colin.king@canonical.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-ds1307.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index fad042118862..49702942bb08 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1673,6 +1673,8 @@ static void ds1307_wdt_register(struct ds1307 *ds1307)
return;
wdt = devm_kzalloc(ds1307->dev, sizeof(*wdt), GFP_KERNEL);
+ if (!wdt)
+ return;
wdt->info = &ds1388_wdt_info;
wdt->ops = &ds1388_wdt_ops;