Dear Rasmus, again: error handling.
In message <20210819095706.3585923-11-rasmus.villem...@prevas.dk> you wrote: > > diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c > new file mode 100644 > index 0000000000..982a66b3f9 > --- /dev/null > +++ b/drivers/watchdog/gpio_wdt.c > @@ -0,0 +1,68 @@ > +// SPDX-License-Identifier: GPL-2.0+ > + > +#include <dm.h> > +#include <dm/device_compat.h> > +#include <wdt.h> > +#include <asm/gpio.h> > + > +struct gpio_wdt_priv { > + struct gpio_desc gpio; > + bool always_running; > + int state; > +}; > + > +static int gpio_wdt_reset(struct udevice *dev) > +{ > + struct gpio_wdt_priv *priv = dev_get_priv(dev); > + > + priv->state = !priv->state; Potential NULL pointer dereference. > +static int gpio_wdt_start(struct udevice *dev, u64 timeout, ulong flags) > +{ > + struct gpio_wdt_priv *priv = dev_get_priv(dev); > + > + if (priv->always_running) > + return 0; Ditto. > +static int dm_probe(struct udevice *dev) > +{ > + struct gpio_wdt_priv *priv = dev_get_priv(dev); > + int ret; > + > + priv->always_running = dev_read_bool(dev, "always-running"); Ditto. > + ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT); > + if (ret < 0) { > + dev_err(dev, "Request for wdt gpio failed: %d\n", ret); > + return ret; > + } > + > + if (priv->always_running) > + ret = gpio_wdt_reset(dev); Ditto. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Even if you aren't in doubt, consider the mental welfare of the per- son who has to maintain the code after you, and who will probably put parens in the wrong place. - Larry Wall in the perl man page