From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 541B7C4338F for ; Thu, 19 Aug 2021 11:46:49 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A98906109F for ; Thu, 19 Aug 2021 11:46:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A98906109F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BFE3F83183; Thu, 19 Aug 2021 13:46:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629373607; bh=X026xNY9Em6ODPnD+M0TSksqSWTUyZZhABvu5bKok/Q=; h=To:cc:From:Subject:In-reply-to:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=zd2nudQ0zD1s0qld8hmClP68QSDlSRSYBFV5NMkiBKSgbzlRzRNe6ZrmfYhqSLBiC 1ZaoMU7LDcxM2US5QX9yyfDBchJfUmsf8Z6Ydz0JTnttB+E1fWQAEWtsQJanb9Psg/ +E3jaksOqZaCS9sz/qr5K3rJmrzfsvrj7Mp6K8OVIJLrv8xYKym7PBiTmq2ikCWHwe 0EH9+SayptRt/OGQUS5e2xIkPg4giOGrl5rtVy00oS0/8iL8rqVJG/SstfaOtfNVAF YNMyWycG6BVP7c+vp867u5+B0OzXzDBfbrKSWMR0H6/uQoETIlGyKHd+ZbAdaCWTcG 3WnjJ/yZvTY5A== Received: from janitor.denx.de (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: noc@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 56B2D83117 for ; Thu, 19 Aug 2021 13:46:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629373604; bh=X026xNY9Em6ODPnD+M0TSksqSWTUyZZhABvu5bKok/Q=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=D9VeyqexMpjMeAm/XyfzjrSVnaSlhWF8KFkz38CcG8KiZ+qo3JTObh37Ezq0CiKCK fqUUaKeLOX2SFSPJkG56mceel6udGsKauI1WcpR6LgI/MPJvLwrFufAAXUQKBIwZsG aaL6kvsGispx2PETI4J6B4H/aB47MZjQG6sXuwU7rjKcGgH+FqFQ6iXFHOf2wPQ3zD kPlPRUFDwIo9i61PCxRsDc9N88ynLclVq5+RL6rj+Re2AAFCUJMlYRYpaVHkGUV0qo uH2TGQexCiLmJBNRBATp8nXDwPwBt5ZlJrEJFtDJO3kYA8TuneUPlrDKdrGca2Xej4 2zm1dSLvRecSQ== Received: by janitor.denx.de (Postfix, from userid 108) id E6077A0148; Thu, 19 Aug 2021 13:46:43 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id 0BFE8A005F; Thu, 19 Aug 2021 13:46:34 +0200 (CEST) Received: from gemini.denx.de (localhost [IPv6:::1]) by gemini.denx.de (Postfix) with ESMTP id E67F21E1772; Thu, 19 Aug 2021 13:46:33 +0200 (CEST) To: Rasmus Villemoes cc: u-boot@lists.denx.de, Simon Glass , Stefan Roese , Tom Rini From: Wolfgang Denk Subject: Re: [PATCH v6 10/12] watchdog: add gpio watchdog driver MIME-Version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8bit In-reply-to: <20210819095706.3585923-11-rasmus.villemoes@prevas.dk> References: <20210819095706.3585923-1-rasmus.villemoes@prevas.dk> <20210819095706.3585923-11-rasmus.villemoes@prevas.dk> Comments: In-reply-to Rasmus Villemoes message dated "Thu, 19 Aug 2021 11:57:04 +0200." Date: Thu, 19 Aug 2021 13:46:33 +0200 Message-ID: <57359.1629373593@gemini.denx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Dear Rasmus, again: error handling. In message <20210819095706.3585923-11-rasmus.villemoes@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 > +#include > +#include > +#include > + > +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: wd@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