From nobody Tue Dec 16 13:52:24 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4EE0C4167B for ; Thu, 30 Nov 2023 03:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231628AbjK3DQD (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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/etherne= t/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) } =20 match =3D 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 =3D match->data; =20 priv->emac.clk =3D devm_clk_get(dev, "hclk"); --=20 2.17.1