Commit 1821b79d authored by Colin Ian King's avatar Colin Ian King Committed by Alexandre Belloni

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: fd90d48d ("rtc: ds1307: add support for watchdog timer on ds1388")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200403110437.57420-1-colin.king@canonical.comSigned-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 3edf29d9
...@@ -1673,6 +1673,8 @@ static void ds1307_wdt_register(struct ds1307 *ds1307) ...@@ -1673,6 +1673,8 @@ static void ds1307_wdt_register(struct ds1307 *ds1307)
return; return;
wdt = devm_kzalloc(ds1307->dev, sizeof(*wdt), GFP_KERNEL); wdt = devm_kzalloc(ds1307->dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
return;
wdt->info = &ds1388_wdt_info; wdt->info = &ds1388_wdt_info;
wdt->ops = &ds1388_wdt_ops; wdt->ops = &ds1388_wdt_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment