From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="h8U/2HO/" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A93B92D59; Tue, 21 Nov 2023 02:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=41TdEsYoLDRD7QCMpUE7oCzBIqXCIxjP5nyED47SHKI=; b=h8U/2HO/cq9SLWGR6DgkDHPCVL HmgCspiG/gquu7NVNxruR7bu3SYFZtlqOYrxtKV3ki/IldV6S2T7GX4Cwru3bBg6OIGlxdtqb5pDE tK8Y/UHV5cJl+6i7Fli8SaT2KDL+Vb3c50zvkvz9WTwRSCmfmFSDgYJKUiPVpF8x4iKZFQmbdKbXI 75Gva1+x/YXAMW7gF6FKXAaoUAkSDZCLnoclbtQGxDS52bVlpWs6M2RSs5k5jm4E3elS/2aoFn9QQ zEpkFWJhpzyug7kuZAXj9/uUqOTawF/Cny2nHfL2ip63bDI+AKeJamxDxVbC9iPZ/N5mCQqsZ2eCO 1sN5fNvA==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:48514) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r5Ns2-0006ps-11; Tue, 21 Nov 2023 10:20:42 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r5Ns3-00046L-IX; Tue, 21 Nov 2023 10:20:43 +0000 Date: Tue, 21 Nov 2023 10:20:43 +0000 From: "Russell King (Oracle)" To: Andrew Lunn Cc: Maxime Chevallier , davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Jakub Kicinski , Eric Dumazet , Paolo Abeni , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?iso-8859-1?Q?K=F6ry?= Maincent , Jesse Brandeburg Subject: Re: [RFC PATCH net-next v2 04/10] net: sfp: Add helper to return the SFP bus name Message-ID: References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> <20231117162323.626979-5-maxime.chevallier@bootlin.com> <00d26b50-56f1-4eac-a37f-36cf321bd46a@lunn.ch> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00d26b50-56f1-4eac-a37f-36cf321bd46a@lunn.ch> Sender: Russell King (Oracle) On Tue, Nov 21, 2023 at 02:00:58AM +0100, Andrew Lunn wrote: > > +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!