Thread (25 messages) read the whole thread 25 messages, 3 authors, 2023-11-23

Re: [RFC PATCH net-next v2 04/10] net: sfp: Add helper to return the SFP bus name

From: "Russell King (Oracle)" <linux@armlinux.org.uk>
Date: 2023-11-21 10:22:42
Also in: linux-arm-kernel, lkml

On Tue, Nov 21, 2023 at 02:00:58AM +0100, Andrew Lunn wrote:
quoted
+const char *sfp_get_name(struct sfp_bus *bus)
+{
+	if (bus->sfp_dev)
+		return dev_name(bus->sfp_dev);
+
+	return NULL;
+}
Locking? Do you assume rtnl? Does this function need to take rtnl?
Yes, rtnl needs to be held to safely access bus->sfp_dev, and that
either needs to happen in this function, or be documented as being
requried (and ASSERT_RTNL() added here.)

The reason is that sfp_dev is the SFP socket device which can be
unbound via sfp_unregister_socket(), which will set bus->sfp_dev to
NULL. This could race with the above.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help