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 E2D57C4338F for ; Thu, 19 Aug 2021 11:43:57 +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 49EBC6108B for ; Thu, 19 Aug 2021 11:43:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49EBC6108B 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 1B38B83146; Thu, 19 Aug 2021 13:43:55 +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=1629373435; bh=4+ANVZw1KKquVKIfBPAo5PE486qlIV488u/ciSlXIa0=; h=To:cc:From:Subject:In-reply-to:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tB/xhXZDa+seta3cwbu4P1kIbu/mEYw3QqE2bEYBrOAVid1snK5oTMOUW1G+6nLNL 1V3rvJIYYQflz3JM40+OV3apkTpntlJCaURH+ZAxbo8y6BNLzFz8ScREhj+inCuslm qJ1t4961Qns7MMAzhnWfocbPhjDVPUoaMezrki4YJ2M/8ejBJ0n9UYx2WoYf+BVyCY a17Ev8Eg3wPwfXZGxxxd3tYa2AMKP6XEcSB8xbo9B+KoC8jWd4devfgKHppWBzzUwG PyJGNMRTpEFA44sDSz7IOfyCB1h7dWpEUlf9xTTXrrWRBjD7OQwSzpZZi4Vnrqhclv SpG9uLcSQqcBg== 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 6562E82EBB for ; Thu, 19 Aug 2021 13:43:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629373433; bh=4+ANVZw1KKquVKIfBPAo5PE486qlIV488u/ciSlXIa0=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=boeZW/kGDjv5avy+TCqgzY+EFlcyfs5wgDX1ONHu/g5uZWUxyj0W+Mr/lWfkyEQ+H xtEMXId9Z1weTgC6+qwtM+gsq8sPpwaESm3GRlF88ROWVZzSDDFVjcmOYbbbFLX/sn L8brbclMKo3ycJFJ0xP9Ybe9tmV8ZApImffxLgY6AFSD8F6gRQoqOFVjBKj7n82EMt GjRxDwDgjdqIKQF1Ep+Kt+fUq1KyOpyIXkrB+PZvNNCOCogzyW2TpopXaBiCukF8fU GPz7U78qZn6HoEgaqEcgQUE5X7da1QEQIzhw/e7VZ1dpjECRu29Y1tudrbUPDK69sG ARLgJDgvWWLsA== Received: by janitor.denx.de (Postfix, from userid 108) id 06175A01F7; Thu, 19 Aug 2021 13:43:52 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id D4F2EA005F; Thu, 19 Aug 2021 13:43:41 +0200 (CEST) Received: from gemini.denx.de (localhost [IPv6:::1]) by gemini.denx.de (Postfix) with ESMTP id C433A1E1772; Thu, 19 Aug 2021 13:43:41 +0200 (CEST) To: Rasmus Villemoes cc: u-boot@lists.denx.de, Simon Glass , Stefan Roese , Tom Rini From: Wolfgang Denk Subject: Re: [PATCH v6 09/12] watchdog: wdt-uclass.c: handle all DM watchdogs in watchdog_reset() MIME-Version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8bit In-reply-to: <20210819095706.3585923-10-rasmus.villemoes@prevas.dk> References: <20210819095706.3585923-1-rasmus.villemoes@prevas.dk> <20210819095706.3585923-10-rasmus.villemoes@prevas.dk> Comments: In-reply-to Rasmus Villemoes message dated "Thu, 19 Aug 2021 11:57:03 +0200." Date: Thu, 19 Aug 2021 13:43:41 +0200 Message-ID: <57297.1629373421@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, In message <20210819095706.3585923-10-rasmus.villemoes@prevas.dk> you wrote: > > diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c > index 5b1c0df5d6..7570710c4d 100644 > --- a/drivers/watchdog/wdt-uclass.c > +++ b/drivers/watchdog/wdt-uclass.c > @@ -61,20 +61,24 @@ static void init_watchdog_dev(struct udevice *dev) ... > + ret = uclass_get(UCLASS_WDT, &uc); > + if (ret) { > + log_debug("Error getting UCLASS_WDT: %d\n", ret); > + return 0; > + } > + > + uclass_foreach_dev(dev, uc) { > + ret = device_probe(dev); > + if (ret) { > + log_debug("Error probing %s: %d\n", dev->name, ret); > + continue; > } As discussed - errors need to be shown to the user, and not only in images with debugging enabled. > @@ -182,22 +186,34 @@ void watchdog_reset(void) > { > struct wdt_priv *priv; > struct udevice *dev; > + struct uclass *uc; > ulong now; > > /* Exit if GD is not ready or watchdog is not initialized yet */ > if (!gd || !(gd->flags & GD_FLG_WDT_READY)) > return; > > - dev = gd->watchdog_dev; > - priv = dev_get_uclass_priv(dev); > - if (!priv->running) > + if (uclass_get(UCLASS_WDT, &uc)) > return; Do I see this crrectly that you remove here the code which you just added in patch 02 of this series? Why not doing it right from the beginning? > + uclass_foreach_dev(dev, uc) { > + if (!device_active(dev)) > + continue; > + priv = dev_get_uclass_priv(dev); > + if (!priv->running) > + continue; Potential NULL pointer dereference. 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 An Ada exception is when a routine gets in trouble and says 'Beam me up, Scotty'.