Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2672840pxj; Mon, 31 May 2021 07:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjK1Yg5cPFIiKHJnSr863QLua9j7LGFHL5+SMkB95LDRnKUk0mzVD6Mss+RAflM/FLrKyN X-Received: by 2002:a05:6402:b89:: with SMTP id cf9mr7333228edb.198.1622473088059; Mon, 31 May 2021 07:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622473088; cv=none; d=google.com; s=arc-20160816; b=E3LCrf8sQJtA2/KtsOQoTygcdwsAKXLkbJg2xOadRCQIyb2ueSwvGRSmp15iyncBml 2Gh/WPgFIF9XVWoqgRIzdv5OEzvzUvTqTB4NVHwrPWf2EamcE6G06dnTuQDgjCNTFT/N rxZlrpsae89hG53SoLpfNUWyU6nC5/GL7QMK270Mvd/i3E8s/YwwYSMZWDofi/chWKr3 dxGW8t5jJz++XTQusO4R/PN/dIZTHKH3wjJ6kyHcU0e0ej3EtDdLfbLmGHAC3mNoAIDJ ipYE+brIbmjCFVd7SF5IUi9F1Zg7VWwn1j8FAmnJyKP0roa5b6qPwcpWNC4vpRvWlPTA uuHw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5Jxshmjd5ORlUOWaR9PSTMtCkLYPba2Rkey84wdUJ7k=; b=qy8gj4a6UcPryVHSzARn/8xqP6HmVA65BASpkC44JSCBxUKRn8Vs/ZEuzqLw/8l2R/ cZ/ZNw8IirGHJDKFhQx+y5/okcCTGKMrMVBnYWOy1oa7crkgUjfvOAeVik2LRgGedl3B Jo5jo3oL6YH7Wh1GbkNL2bVXeU0lyfqxOm7u486BSGjxnz5IcjA7z06It30qxFPoHuZy 8DmpNyqlmXZTx9pY1wVVvG2GjvDY94uP58tzdODLIIQmqW1EAlKikXv3/Gdm/AKbLf0t H0IUFjEIzkG22vnlS4taFYFMsCTQYn44rnu3A8m0PUI1co4/QDTk3Hg3+4wh2CqofXJI WdmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gzAXO0qe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si15395322ejq.124.2021.05.31.07.57.45; Mon, 31 May 2021 07:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gzAXO0qe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231913AbhEaO6g (ORCPT + 99 others); Mon, 31 May 2021 10:58:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:36536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbhEaOFA (ORCPT ); Mon, 31 May 2021 10:05:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 46A9961964; Mon, 31 May 2021 13:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468301; bh=eneXgJadla0FXNynniX2GwEnmQwZmwoZoySbbR2JdRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzAXO0qegMjVwvGLesPrU5s2OsKBBvjlRyCi44R15eAlPLmsOP1Z+sZqAecOti9u2 6l0GKkJrhyCDSUy8uZIPvLDn0AN9yum6ZNkkDPnq0wb6oNiPtHnK2oWjPcI84H2fkr lDwZfIHRZsBgbrPBmsEm65R6dIO0aMPEjBXWeiRc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kalle Valo , Sasha Levin Subject: [PATCH 5.10 157/252] libertas: register sysfs groups properly Date: Mon, 31 May 2021 15:13:42 +0200 Message-Id: <20210531130703.335779856@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman [ Upstream commit 7e79b38fe9a403b065ac5915465f620a8fb3de84 ] The libertas driver was trying to register sysfs groups "by hand" which causes them to be created _after_ the device is initialized and announced to userspace, which causes races and can prevent userspace tools from seeing the sysfs files correctly. Fix this up by using the built-in sysfs_groups pointers in struct net_device which were created for this very reason, fixing the race condition, and properly allowing for any error that might have occured to be handled properly. Cc: Kalle Valo Link: https://lore.kernel.org/r/20210503115736.2104747-54-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/libertas/mesh.c | 28 +++----------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/mesh.c b/drivers/net/wireless/marvell/libertas/mesh.c index c611e6668b21..c68814841583 100644 --- a/drivers/net/wireless/marvell/libertas/mesh.c +++ b/drivers/net/wireless/marvell/libertas/mesh.c @@ -801,19 +801,6 @@ static const struct attribute_group mesh_ie_group = { .attrs = mesh_ie_attrs, }; -static void lbs_persist_config_init(struct net_device *dev) -{ - int ret; - ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group); - ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group); -} - -static void lbs_persist_config_remove(struct net_device *dev) -{ - sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group); - sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group); -} - /*************************************************************************** * Initializing and starting, stopping mesh @@ -1009,6 +996,10 @@ static int lbs_add_mesh(struct lbs_private *priv) SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent); mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST; + mesh_dev->sysfs_groups[0] = &lbs_mesh_attr_group; + mesh_dev->sysfs_groups[1] = &boot_opts_group; + mesh_dev->sysfs_groups[2] = &mesh_ie_group; + /* Register virtual mesh interface */ ret = register_netdev(mesh_dev); if (ret) { @@ -1016,19 +1007,10 @@ static int lbs_add_mesh(struct lbs_private *priv) goto err_free_netdev; } - ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); - if (ret) - goto err_unregister; - - lbs_persist_config_init(mesh_dev); - /* Everything successful */ ret = 0; goto done; -err_unregister: - unregister_netdev(mesh_dev); - err_free_netdev: free_netdev(mesh_dev); @@ -1049,8 +1031,6 @@ void lbs_remove_mesh(struct lbs_private *priv) netif_stop_queue(mesh_dev); netif_carrier_off(mesh_dev); - sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); - lbs_persist_config_remove(mesh_dev); unregister_netdev(mesh_dev); priv->mesh_dev = NULL; kfree(mesh_dev->ieee80211_ptr); -- 2.30.2