public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] net: hsr: Add error handling in hsr_portdev_setup()
@ 2023-09-23 12:24 liuhaoran
  2023-09-28 13:05 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: liuhaoran @ 2023-09-23 12:24 UTC (permalink / raw)
  To: davem; +Cc: edumazet, kuba, pabeni, netdev, liuhaoran

This patch adds error-handling for the hsr_port_get_hsr()
inside the hsr_portdev_setup().

Signed-off-by: liuhaoran <liuhaoran14@163•com>
---
 net/hsr/hsr_slave.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
index e5742f2a2d52..ac7d6bdef47e 100644
--- a/net/hsr/hsr_slave.c
+++ b/net/hsr/hsr_slave.c
@@ -141,6 +141,10 @@ static int hsr_portdev_setup(struct hsr_priv *hsr, struct net_device *dev,
 	}
 
 	master = hsr_port_get_hsr(hsr, HSR_PT_MASTER);
+
+	if (!master)
+		return -ENODEV;
+
 	hsr_dev = master->dev;
 
 	res = netdev_upper_dev_link(dev, hsr_dev, extack);
-- 
2.17.1


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

end of thread, other threads:[~2023-09-28 13:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-23 12:24 [PATCH] net: hsr: Add error handling in hsr_portdev_setup() liuhaoran
2023-09-28 13:05 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox