netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [net/ethernet] arc_emac: Add error handling in emac_rockchip_probe
@ 2023-11-30  3:13 Haoran Liu
  2023-12-02  4:11 ` Jakub Kicinski
  2023-12-06  5:35 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Haoran Liu @ 2023-11-30  3:13 UTC (permalink / raw)
  To: davem
  Cc: edumazet, pabeni, heiko, netdev, linux-arm-kernel, linux-rockchip,
	linux-kernel, Haoran Liu

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 <liuhaoran14@163.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-06  5:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-30  3:13 [PATCH] [net/ethernet] arc_emac: Add error handling in emac_rockchip_probe Haoran Liu
2023-12-02  4:11 ` Jakub Kicinski
2023-12-06  5:35 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).