Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp341111rdh; Thu, 23 Nov 2023 05:35:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEW9geFReYIoWpb/PnvvFjyG/X+457ABxCNzgGmCbTT01RB7N+VyKPTOknUsRlI/7OTJzgX X-Received: by 2002:a17:90b:3a84:b0:27d:5964:4eec with SMTP id om4-20020a17090b3a8400b0027d59644eecmr5254219pjb.1.1700746515085; Thu, 23 Nov 2023 05:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700746515; cv=none; d=google.com; s=arc-20160816; b=dLTpPUyYBcxXDXGADUQxXyQxmItcTzc6ZEw+dh14skVfLnl5RJgysuQ23+1y34tILK ZR65wUt9wLHt040sKdSDH+tSbdOjWOy1ENe7pb/iRZ3h36ILUPxUu6+xLEAu1RoJRbX7 FY2c/ylB2d/JeXpxPq4dddr/m9HuuNGi+PaB5fWvDFgKOcUlHeOrcVkK1sIJ6keuEv8/ 1vVk/qgKp2WGAOFdbOnvqLqsq9ik7d4EgUpg83XhmwD3ja/lB1GyjpUsuupjATAckLHt 2+K8EDKFkIz+S+Fyqbc4wJh2iUlENqMnwVUu7qkYNaFy/2usfKQy25Saa96DBvybSD2q oJxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=mI4znOI0zE5PCCzZTTeLMyK+ZXMtNz24QJhN8KXDmLA=; fh=oSGELcIAoc4DkvlM789ynW7StygR8vt8a//1Oadepd4=; b=jjexXTJgVCrYlWEi6Cy5J7gA2FoUDPmf5xTVB8y3dceYJxNThbiYAoRyNHl7eMaXw2 9nb+cu3QAUeASazWrZuJxsHHiSIxqtx0raWG7VcEi3Z1OBUaabm7/NXqdTckbrHX563O FBAhkFwJjK8STqCkaZETFNK/WXfy1z5/1StOWyOyiEPrlsq/3WDunFG8OubaLoQZs0+A fqiXCnWP4rO9uOCttbP29Bn4qd3pTST5XKBlU/Jc0BrdhC8x6QiBL5ob323lZrhoEp6H W8TkNtb8xBL2igiohs+s+ReWPpPKXXX4+oOwn7FI2M1LMeq4YsDpWOMAL4Xdf4hamODz Kmqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EtcX4T8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z15-20020a17090acb0f00b00285177b43d3si1788086pjt.111.2023.11.23.05.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 05:35:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=EtcX4T8V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D5D26803A5B8; Thu, 23 Nov 2023 05:35:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345488AbjKWNfD (ORCPT + 99 others); Thu, 23 Nov 2023 08:35:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345468AbjKWNfC (ORCPT ); Thu, 23 Nov 2023 08:35:02 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C8DC1; Thu, 23 Nov 2023 05:35:08 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DD7DD1C0007; Thu, 23 Nov 2023 13:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700746505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mI4znOI0zE5PCCzZTTeLMyK+ZXMtNz24QJhN8KXDmLA=; b=EtcX4T8VhqjpHCjMpiAz1lTycXWcOjenC90NFWYOwNIhxgMZCuHf2pxZbLcclEXAXOE63P 2hu19ZFS7LgZITw3sRvmmVQkCWWbuy/9qOUihaTgl1p28zlnSIiHRoHYd/IZ+kTOQEB/1s jWV9pfUI8PxVdlKHpKUXh7WyYu160a0hFynJxTEcxbETVLmPIB7x2foY8DaUjh6UB44ST8 hZjDRtQ/QaTMSacxb5rjNOlDvwncJKdnY4Qzs89ZlZ9yeYFikgaKK2vTxgDN3xGLD527tT Tevhxp97kPmtXnkFhTKio9ZFgG2aARv8x8AJzeIXQRToNSXG+FM9ZY0OAQOCbQ== Date: Thu, 23 Nov 2023 14:35:02 +0100 From: Maxime Chevallier To: "Russell King (Oracle)" Cc: Andrew Lunn , 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 , =?UTF-8?B?S8O2cnk=?= Maincent , Jesse Brandeburg Subject: Re: [RFC PATCH net-next v2 04/10] net: sfp: Add helper to return the SFP bus name Message-ID: <20231123143502.3a9a9047@device.home> In-Reply-To: References: <20231117162323.626979-1-maxime.chevallier@bootlin.com> <20231117162323.626979-5-maxime.chevallier@bootlin.com> <00d26b50-56f1-4eac-a37f-36cf321bd46a@lunn.ch> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: maxime.chevallier@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 23 Nov 2023 05:35:14 -0800 (PST) Hi Andrew, Russell, On Tue, 21 Nov 2023 10:20:43 +0000 "Russell King (Oracle)" wrote: > 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. > That's right, I'll add an assert and document it, thanks for spotting this. Maxime