Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp40733rdb; Wed, 29 Nov 2023 19:16:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1ptJD835UPTNJkPMOfByj19WUAgAH4+g31OUec5DKflXwsfuRQzB4iSEETS4pmld/1ahg X-Received: by 2002:a05:6a21:33aa:b0:18a:d7a8:5e65 with SMTP id yy42-20020a056a2133aa00b0018ad7a85e65mr23772137pzb.0.1701314180753; Wed, 29 Nov 2023 19:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701314180; cv=none; d=google.com; s=arc-20160816; b=1IsFGX45tHF7oGeXy4hEPZr4Y0Yu81IK2ZYRu3CsPkrJnLYY8TOID+TT5EuziFW3Sa 3DQ9WLDIzPdPcfRNjTnIqlnwY8cjqD3fR3SkhfovYUz2ECmnb/w64NXDcgCJ6asBYZV2 XlRJfLU4M22XTVpeGKpP/RMUcjvvpYTviL2qlOPz4wELBghynLI92D9GXk8mjRG6itX3 a/P2NYSXi5uSBWlKys99ZqA0GT1pB5mWuhDuCRu2QDeUi9+r77Mja0dsnzbHfy1SbFsW Dxacf/QMIZtDslSV2mgFVynWXFHeGuy6VApYvaT4zruZakFGbQpv3ry/mfLtmdhXZE4U fnvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=UfjhIxyGPgUBRRrgHEZRqAC26KRpErr7rMhG9xIdpcU=; fh=7qQvyfYVmsfasVmoPbMWDWlVeOscQazUBmwW0yb5EM0=; b=NC0KbJXDRysvTts5c2XSMODtOnezJDQf2igF9/2px2uxVV/QfUst2N4HqTl+aFYbrj BNHIUQ5+MDeXpcY/x9k2UCDHL/3fio33a2QdlKiqV9PEQPd4mSLE8Rt1XpwvUDjaqXPi 9wXEu5EYDtYrJKhjGVMxENDNZg1+C7UkOKX98W7TXhwkIgypMoVn2Be1Fbi8ct4QjlFz D0xvlfV3v8rF6tdos6vQBWOGnBKr3rewu6XLgd0iDM3HP80I5sgZ2Fe0Lhh1HAEqJyCX ZW9T0MxN6U4mn8jV+HQ8pF+jq/MpTrKH9XL0yehXjZwRIdXZS7gv/kWUgwob92u6k75L eDCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=ZFFG9NCD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s20-20020a17090b071400b0028515f9b7d1si366291pjz.168.2023.11.29.19.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 19:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=ZFFG9NCD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4F80E8030A7B; Wed, 29 Nov 2023 19:16:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbjK3DQD (ORCPT + 99 others); Wed, 29 Nov 2023 22:16:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbjK3DQC (ORCPT ); Wed, 29 Nov 2023 22:16:02 -0500 Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 431121A6; Wed, 29 Nov 2023 19:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=UfjhIxyGPgUBRRrgHE ZRqAC26KRpErr7rMhG9xIdpcU=; b=ZFFG9NCDo5w5m5kc8Nih7jn82lb8VyQ7c1 /b8/AW+icz0K+aVbmvLFOU0UzoFafKs3cQwOuHJRuSowCYMRSPDtE0cQ4d3AhaDd 3FOE+UTr31EiBB10Hnmd3BGECauHcIxz4V1tsVWTapYwatC7zpn4CQtOFATqOsJ7 tTjhORLiI= Received: from localhost.localdomain (unknown [39.144.190.126]) by zwqz-smtp-mta-g1-2 (Coremail) with SMTP id _____wDH13_P_WdlBXH7AQ--.52667S2; Thu, 30 Nov 2023 11:13:21 +0800 (CST) From: Haoran Liu To: davem@davemloft.net Cc: edumazet@google.com, pabeni@redhat.com, heiko@sntech.de, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Haoran Liu Subject: [PATCH] [net/ethernet] arc_emac: Add error handling in emac_rockchip_probe Date: Wed, 29 Nov 2023 19:13:18 -0800 Message-Id: <20231130031318.35850-1-liuhaoran14@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: _____wDH13_P_WdlBXH7AQ--.52667S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WFWfKw13KF1fuw1UKryUWrg_yoW8Gw43pw 4DCr9xCw1kWw17Za97GayrAF4Yq3W5KFWjgF9rGa1fua45AFyUXry0qa45ur1UJr42kFya kr4UA34fZan8X37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zieOJ7UUUUU= X-Originating-IP: [39.144.190.126] X-CM-SenderInfo: xolxxtxrud0iqu6rljoofrz/xtbBcgU4gletj6IPXAAAsJ X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 19:16:18 -0800 (PST) This patch introduces error handling for the of_match_node call within the emac_rockchip_probe. Previously, there was no check for the return value of of_match_node, which could result in improper behavior if the device tree match was unsuccessful. Although the error addressed by this patch may not occur in the current environment, I still suggest implementing these error handling routines if the function is not highly time-sensitive. As the environment evolves or the code gets reused in different contexts, there's a possibility that these errors might occur. Addressing them now can prevent potential debugging efforts in the future, which could be quite resource-intensive. Signed-off-by: Haoran Liu --- drivers/net/ethernet/arc/emac_rockchip.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c index 493d6356c8ca..f6f1390b77f6 100644 --- a/drivers/net/ethernet/arc/emac_rockchip.c +++ b/drivers/net/ethernet/arc/emac_rockchip.c @@ -134,6 +134,11 @@ static int emac_rockchip_probe(struct platform_device *pdev) } match = of_match_node(emac_rockchip_dt_ids, dev->of_node); + if (!match) { + dev_err(dev, "No matching device found\n"); + return -ENODEV; + } + priv->soc_data = match->data; priv->emac.clk = devm_clk_get(dev, "hclk"); -- 2.17.1