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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 CF6E5C4338F for ; Thu, 19 Aug 2021 12:32:17 +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 7977960551 for ; Thu, 19 Aug 2021 12:32:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7977960551 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 C9B9080EE9; Thu, 19 Aug 2021 14:32:13 +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=1629376334; bh=2QEKiq8USzAL92kvtkrfX7kdWH2tLabLPbLeG8Kd/W4=; h=To:cc:From:Subject:In-reply-to:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NCjHFpXQzLWYKvsD7KfNF9xW9Jc1Dlm5tB+gtNHUoW/iPsPPafG4sbuLazavqsulb Cj+xJio1vjskX90YORyxyI6FAMq8hxKqEgrchH4qHRc3wo9PfDm4865RGUNwz5ETZH VvtEJ0LUkrZFFg2gimk+syip2lQmuRgrkv2zSyU1LJgIWMITr4/PYJa9gJY3D1/pIk D1ognmdXUSPPw5UmaCNALXFFCjqQuBhPOgj7fC47I//OnsSryf+6sRikyP4mjdTFzj 7BUkcmiANvKFDqmvq/0XTNsjeoOpz//dOyFMpBm1NX8LiM860p9lZNTWesXU9IN3IU esx4DLgw7+/rw== 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 A989A80EE9 for ; Thu, 19 Aug 2021 14:32:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629376331; bh=2QEKiq8USzAL92kvtkrfX7kdWH2tLabLPbLeG8Kd/W4=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=OZCSeIqAUl/4EgucrLJ0D7LKXyjcBCOXPUf+hcZIkUnmOXqyXq01z6kiODz57c5kP 2aguX5nzb7/0qLu9C8vfH6TIGBRvA32JRdbj3gz/9ZCVNEDyXNYX0iJvz6ZIAGa+tJ aEDI1SzDrYNqkCtfqZckzE+x68slJLfGNnx31TD9xuhvgtJKcFA3aTc5MVkidht8hM KKImv8HdTT9FGdUZyQoOIfcPxoYGUIVlKNBA8EqoOfJ2J54fGUVtpLMooffr/46apo Lf99N+i1X5MkG56iYY4z5xBSMqOC8xHgUoJoU0YVRQ0syRWs3u8gOHEfyuVYim8RfV U4NasAVsQL9PQ== Received: by janitor.denx.de (Postfix, from userid 108) id 2DE15A01F7; Thu, 19 Aug 2021 14:32:11 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id 6C559A0122; Thu, 19 Aug 2021 14:32:01 +0200 (CEST) Received: from gemini.denx.de (localhost [IPv6:::1]) by gemini.denx.de (Postfix) with ESMTP id 2335A1E1772; Thu, 19 Aug 2021 14:32:01 +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: <62540f7b-0e07-8759-8e12-125527c2edec@prevas.dk> References: <20210819095706.3585923-1-rasmus.villemoes@prevas.dk> <20210819095706.3585923-11-rasmus.villemoes@prevas.dk> <57359.1629373593@gemini.denx.de> <62540f7b-0e07-8759-8e12-125527c2edec@prevas.dk> Comments: In-reply-to Rasmus Villemoes message dated "Thu, 19 Aug 2021 14:09:24 +0200." Date: Thu, 19 Aug 2021 14:32:01 +0200 Message-ID: <61767.1629376321@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 <62540f7b-0e07-8759-8e12-125527c2edec@prevas.dk> you wrote: > > >> +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. > > No, no and no. If allocation of the (driver or uclass) private data > fails, the device probe would have failed, so this code can never get > called with such a struct udevice. Famous last words... > Perhaps try doing a > > git grep -10 -E 'dev_get(_uclass)?_priv' > > and see how many cases you can find where that is followed by a NULL check? The existence of bad code is not a justification to add more of it. 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 No, I'm not going to explain it. If you can't figure it out, you didn't want to know anyway... :-) - Larry Wall in <1991Aug7.180856.2854@netlabs.com>