diff mbox series

AW: [PATCH][next] rtc: ds1307: check for failed memory allocation on wdt

Message ID 54a09b5502ee45e9a926a025ae576498@bfs.de
State Superseded
Headers show
Series AW: [PATCH][next] rtc: ds1307: check for failed memory allocation on wdt | expand

Commit Message

Walter Harms April 2, 2020, 1:40 p.m. UTC

diff mbox series

Patch

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index fad042118862..95c5b6facc59 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1665,14 +1665,16 @@  static const struct watchdog_ops ds1388_wdt_ops = {

 };

-static void ds1307_wdt_register(struct ds1307 *ds1307)
+static int ds1307_wdt_register(struct ds1307 *ds1307)
 {
        struct watchdog_device  *wdt;

        if (ds1307->type != ds_1388)
-               return;
+               return 0;

        wdt = devm_kzalloc(ds1307->dev, sizeof(*wdt), GFP_KERNEL);
+       if (!wdt)
+               return -ENOMEM;

        wdt->info = &ds1388_wdt_info;
        wdt->ops = &ds1388_wdt_ops;
@@ -1683,10 +1685,13 @@  static void ds1307_wdt_register(struct ds1307 *ds1307)
        watchdog_init_timeout(wdt, 0, ds1307->dev);
        watchdog_set_drvdata(wdt, ds1307);
        devm_watchdog_register_device(ds1307->dev, wdt);
+
+       return 0;
 }
 #else
-static void ds1307_wdt_register(struct ds1307 *ds1307)
+static int ds1307_wdt_register(struct ds1307 *ds1307)
 {
+       return 0;
 }
 #endif /* CONFIG_WATCHDOG_CORE */

@@ -1979,9 +1984,9 @@  static int ds1307_probe(struct i2c_client *client,

        ds1307_hwmon_register(ds1307);
        ds1307_clks_register(ds1307);
-       ds1307_wdt_register(ds1307);
+       err = ds1307_wdt_register(ds1307);

-       return 0;
+       return err;

 exit:
        return err;