Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5636637rwb; Mon, 5 Dec 2022 01:49:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf5AnaFBSMvAanb8qJmUkue/ng7UGNsYA3kcs6iJ1KEPcUgq/B3KbvQ1kyoMpL55KMJFJfQa X-Received: by 2002:aa7:9045:0:b0:56c:a321:eecb with SMTP id n5-20020aa79045000000b0056ca321eecbmr84617279pfo.19.1670233768332; Mon, 05 Dec 2022 01:49:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670233768; cv=none; d=google.com; s=arc-20160816; b=yzDNgpoMKx6PgwKnJi6WKjdzXLFK/H0AQOvRm4PoKllOt0WNNqvAqPFzd7s7NtqCrO umguFRFo7xejS83dmfL24NGKrWWhRujQbIxPhd8pfEymX8NkMuP/iN2dafgbKmeIQW3i 2QYZWVK5Ee71mi6zAAKMRlAXq+NwrypFh13azWBUvCIa0wfUlH3dvB45gAvZi4mOz8fD UQsxcZ2gZ9p/dyRW1LrfQghNyZX8JJe3nJYj23jLWW8NZ49mGkYkGJZs2TjFGQ6Vycrc SnytTtNZlcD4nJjEAtRuiLn1AVbDftBhRHP0NwlhxPSJzVexRxk2BTRMIv4KDH8rsid7 tVAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xoLfzXVkjo8xAm6ZoyhPEG35GhkaRRBgemIJLYp+/88=; b=HnZjiNCUChVLLeyOxFgveyvxBv/Hr72ZN5+zIcfOIuk2NHKCoaNhRYd2UIgsvxvXra woAzVHj6qWnV+yK6pwKb0gOKgpObiEijO8czNFj+srOdt38v1iun1K9FzKT31lz3JuCR 8dqRG6VC2Fyn9J7hHSDZJK5Md/CO65hRADdXpGr2GcoFqb3iADZYqtvNMI2BuI4pHDiT UDxdLitwp8CFA2aZ7RtN5Y0OikDU5R3xVx/W1TqQvBagSLjY6rVOxorXyKUh/D5QLL/a iYGDj7Sd11tQmiKXcB376SjRuMNACLEFQVW4LhV31gOr90HQuq03pM+0oi1L/5WeT6Vo Dq5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="at/2Q0D1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170902ea0b00b001891fd4ebf0si15983282plg.495.2022.12.05.01.49.17; Mon, 05 Dec 2022 01:49:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="at/2Q0D1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbiLEJhX (ORCPT + 82 others); Mon, 5 Dec 2022 04:37:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbiLEJhV (ORCPT ); Mon, 5 Dec 2022 04:37:21 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D47B11143; Mon, 5 Dec 2022 01:37:20 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id f7so14917230edc.6; Mon, 05 Dec 2022 01:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xoLfzXVkjo8xAm6ZoyhPEG35GhkaRRBgemIJLYp+/88=; b=at/2Q0D1obdj6fS8XI2naRo6awU7eHZGEWqXOPYMdiqm/57m6I4dCLR4lDQgud15Pz U0z5ByppO1SWj8t/Hs/vTne54kXZ1lj4eufTYHCXVHeJKD8Qk1MpNQ+yTOTRQ0ETWs7z kpHvAPbAn6to7RVtzTyQAN0r0JPL+2Y4c77gZPDMpO4w8jKCcHKUZrhhKvtQYNT+i2Zj YhUrY70Hsuqm6j7ykLSvj35Rhecx0cjGBA3bRVXpGgV/wPg8NsO8ObTj6S8vdznANRPQ 28K9D4ihK0Qa561S26ZOKBPPPSMYkWhatoUFL47qFdWVs8aGDOy3+XXwiAPR+bhp2O/m 5A/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xoLfzXVkjo8xAm6ZoyhPEG35GhkaRRBgemIJLYp+/88=; b=uufjK1DOWmyv2SbdqJ5ixlU6SptxFB40F3FgGjxIggPytml1RfKyOH6Q5YzXwXxFF0 yvD5gSNdJ7TYskxz5sBfqlLERC5o+0gInwFQiesknT46dG4c3VmITKCxS5y8SVhM452r YBvq/2SiSSLL/EQTSqomGEVu1XwEyGJjulERt5q+/EUdRcn643102fIenN9OGY7x3Ogr UXe1GH3bJ7O/b19M4HKDDbnW8jPmYCDwS0om2/ij5YCskbPNDqSGHeQUICxIqIgHf/VK A7GT2q6zNBXJYuhbX4D0TIcwl4743BGdKoVjaGpajxPoZpVVR79jp4+GXRk6EOc3ZfET 9f2Q== X-Gm-Message-State: ANoB5pnHS1K/mAeIWPZsyySfvrRdhJxQjB+I32f+yfDhplh4182mU06M C63TgdC47La6+uFYUs67aVI= X-Received: by 2002:a05:6402:d6:b0:458:b42e:46e6 with SMTP id i22-20020a05640200d600b00458b42e46e6mr73681443edu.375.1670233038822; Mon, 05 Dec 2022 01:37:18 -0800 (PST) Received: from gvm01 (net-2-45-26-236.cust.vodafonedsl.it. [2.45.26.236]) by smtp.gmail.com with ESMTPSA id x3-20020a05640226c300b004677b1b1a70sm5960294edd.61.2022.12.05.01.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 01:37:17 -0800 (PST) Date: Mon, 5 Dec 2022 10:37:25 +0100 From: Piergiorgio Beruto To: "Russell King (Oracle)" Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: Re: [PATCH v2 net-next 1/4] net/ethtool: add netlink interface for the PLCA RS Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Mon, Dec 05, 2022 at 09:28:51AM +0000, Russell King (Oracle) wrote: > On Mon, Dec 05, 2022 at 02:41:35AM +0100, Piergiorgio Beruto wrote: > > +int ethnl_set_plca_cfg(struct sk_buff *skb, struct genl_info *info) > > +{ > > + struct ethnl_req_info req_info = {}; > > + struct nlattr **tb = info->attrs; > > + const struct ethtool_phy_ops *ops; > > + struct phy_plca_cfg plca_cfg; > > + struct net_device *dev; > > + > > + bool mod = false; > > + int ret; > > + > > + ret = ethnl_parse_header_dev_get(&req_info, > > + tb[ETHTOOL_A_PLCA_HEADER], > > + genl_info_net(info), info->extack, > > + true); > > + if (ret < 0) > > + return ret; > > + > > + dev = req_info.dev; > > + > > + // check that the PHY device is available and connected > > + if (!dev->phydev) { > > + ret = -EOPNOTSUPP; > > + goto out; > > + } > > This check should really be done under the RTNL lock. phydevs can come > and go with SFP cages. > > > + > > + rtnl_lock(); Good point Russell, I'll fix that. And I wish to seize the opportunity to remark that the same problem may be present in cabletest.c (see below). Maybe we should post a patch to fix that? Thanks, Piergiorgio int ethnl_act_cable_test(struct sk_buff *skb, struct genl_info *info) { struct ethnl_req_info req_info = {}; const struct ethtool_phy_ops *ops; struct nlattr **tb = info->attrs; struct net_device *dev; int ret; ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_CABLE_TEST_HEADER], genl_info_net(info), info->extack, true); if (ret < 0) return ret; dev = req_info.dev; if (!dev->phydev) { ret = -EOPNOTSUPP; goto out_dev_put; } rtnl_lock();