Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4738669rdh; Wed, 29 Nov 2023 09:16:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqPQDIpDGD/3mTz9PI/q2riqaIo/0GHGqeLmIWe6A+b323vAlvRwikE7mfUdTc80oSbU3a X-Received: by 2002:a17:902:e845:b0:1cf:57b3:2665 with SMTP id t5-20020a170902e84500b001cf57b32665mr23830045plg.11.1701278173772; Wed, 29 Nov 2023 09:16:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701278173; cv=none; d=google.com; s=arc-20160816; b=YbOZ+NplC9PoURwGQMkaFFZP7BoEwtcnkV6eD2g1pP0J9oP/YuQpdB635EQm75LjJZ ciGfwYhL44i5nkMXW9sux4ngAEf6g8QLiq+0iDiPF6OiaMXj+MJBUtt7Q5ZNxxkgLpx1 s18FLmikyU0bsrO/fpMVLdjIjWjSpj8w3dQ7urhSdXS7WBwp29pPLT85YD/fEVPHwy4f GZaKMFzZ1EufVHAj/fX6/xnEDb4tXkMneHJt2hAPIEscPViJtMcQWY/DQFfO0RbBYwM2 fL0YsxPPZviRuXLZcPs+qVezm1oD5peSKxxBCOwEkwvajYqFAYEsolGwZRj+ZNOqHw93 yBmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=fi6pfw/YrdlpRPQlqpuxTgYt0q8n78JWGSCcDcbp5EI=; fh=b3ad/R8k6G1lczIHXfE63iLANHgBXTlfxJXNpefdhr0=; b=CHLBEnQFI+hnmRvIge2moSvki0wzVqVZooCDV7dWlvOwsuo4iY1R4mFBdSJqScAwtl Sar1azh9VOscWaH2tJsDkS+U47Lg28qj6UsCYfbL2TNKx2wFsGjzc5D3VYaRUM0L3AYn q37t2ug7Isaq7rBowqIXsGb/9j8yJ7qu1fJSb6tRmAcbaipdYlS28nJDyKXveANfMys8 pwcgwF3LTVi9s/zJK5sKw4bKBHZ79RqZsFRSBfjbeXzj271IeRlR739YYtPAytv3dpXj pLplF4+sIZk5fcXAxfMxV7RF3EVsIMKRukzr3vxfoOh3LLqttuDCYwgC0zwh/WboB2UQ vp8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="i4pse/XM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id o17-20020a170902779100b001d0004bf629si3436274pll.197.2023.11.29.09.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 09:16:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="i4pse/XM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DAB6680B131F; Wed, 29 Nov 2023 09:16:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbjK2RPx (ORCPT + 99 others); Wed, 29 Nov 2023 12:15:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjK2RPv (ORCPT ); Wed, 29 Nov 2023 12:15:51 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E3DFBC; Wed, 29 Nov 2023 09:15:57 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5C662E0004; Wed, 29 Nov 2023 17:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701278156; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fi6pfw/YrdlpRPQlqpuxTgYt0q8n78JWGSCcDcbp5EI=; b=i4pse/XMReNnftJ2DWqBLM7jpvYxZPwRWmWUEakFhPmk2HCamL/ds+2m58H3Ce/FcdkE+f S+20MoxlcdoyCAIf6H1l6po+cFGyUk/3AOpPXeLp4PPTay1ItCwJ9O0H1SA5KJ7WUl5isz 21iBx0ds/o/eeE2p2AX9bKDkREHNqrbHXhmKfEgcs+3MdPFfxHCHYneAAX8kFuikjYjhxA Mo2YrbnP/BnbOxS9xf41dmjT3mDAwRmeI8CG7DT+Dt2sJcTpJV0Kw/r/We9vnPGLKlXdmt x6ZWVhtk0y8ydlfh9qUfIYLqU/enO6Nw/n3iD3xVle2Md8ZJIWq2oyiuH0anig== Date: Wed, 29 Nov 2023 18:15:55 +0100 From: Alexandre Belloni To: Haoran Liu Cc: claudiu.beznea@tuxon.dev, sre@kernel.org, nicolas.ferre@microchip.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [power/reset] at91-sama5d2: Add error handling in at91_shdwc_probe Message-ID: <20231129171555abae472b@mail.local> References: <20231129132939.34047-1-liuhaoran14@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231129132939.34047-1-liuhaoran14@163.com> X-GND-Sasl: alexandre.belloni@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 29 Nov 2023 09:16:11 -0800 (PST) On 29/11/2023 05:29:39-0800, Haoran Liu wrote: > This patch adds error handling to the at91_shdwc_probe function > in drivers/power/reset/at91-sama5d2_shdwc.c. The function > previously did not handle the case where of_match_node could fail, > potentially leading to unexpected behavior if the device tree match > was unsuccessful. > > Signed-off-by: Haoran Liu > --- > drivers/power/reset/at91-sama5d2_shdwc.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c > index e76b102b57b1..2ac566c83aec 100644 > --- a/drivers/power/reset/at91-sama5d2_shdwc.c > +++ b/drivers/power/reset/at91-sama5d2_shdwc.c > @@ -353,6 +353,11 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) > return PTR_ERR(at91_shdwc->shdwc_base); > > match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node); > + if (!match) { Can you elaborate how this will ever happen? > + dev_err(&pdev->dev, "No matching device found\n"); > + return -ENODEV; > + } > + > at91_shdwc->rcfg = match->data; > > at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL); > -- > 2.17.1 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com