Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2744596pxj; Mon, 31 May 2021 09:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx93oelythTVCPDpF5UqsMQEOC2Fl1mIA0+FDGzDsQPlh8n+Szv5g5X/Z0tzkwXj8kz9l92 X-Received: by 2002:a17:906:1444:: with SMTP id q4mr23939073ejc.459.1622479134466; Mon, 31 May 2021 09:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479134; cv=none; d=google.com; s=arc-20160816; b=Tke3UJhcZlaLDTJRajFl31qNSSKajAE9VP6XALVAqLxFSBYL6VzGcG5cMXo36+UrmY y/mfZaj/SzaxJE2/tsh2sM2pap/a2hWMsM25rG5Ehr0MwL5kCr8ndUcRHfUj2ueoSAkb kKeAqrb6UfMUZ15b9PiCe6r10PF/R0NiChsKjpgeEDkkWmhohoS2XwlTFv4Ne8R3UP0U 1kwKIlz2zv8hwMuiRCpwRZ0zLbaLK+sVzsWsz+YI/QfE2WUM7cCiwge8A57aAjrnOrWw OuDUkCFDqlhjiTj19knKzpr52tKEp8A3s6if2/WdUlibjhHi3lxReNOFy2WmTLyxBfXy 9laQ== 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=iYbzIgP0n8IIzWx730FZf+SpGclVogvIS+75J9gEOgg89Yf3v61vzIOg8YB1gZrGMJ PentCZahS/Fw0dFTYicLZ9k2BV06LvHeAlF2jt3nxG6eCU8CN8cVii7T1uxm0oQdQvHt GwwZZ84sku44X3+h0hyjo2yvRtO9LHg5lG8Cd9ThNGKiidYP6FdHTrwyWE0zhiNxwLWL vijwOn0X0nNSvEsn3z6aSxTgedIaWC2mcgd8iVJDalGJMGDHMPezY5hoYtZ3+5rTIVYa zQY9CKLdWdAFGLz8TEauQdbVlRsaGsoixx7+wVjKJWqwo6YrTFExhshvyCJ9mFCBBPH8 3zbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="PmYr/xhl"; 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 c18si13339267ejs.425.2021.05.31.09.38.30; Mon, 31 May 2021 09:38:54 -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="PmYr/xhl"; 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 S234144AbhEaQhq (ORCPT + 99 others); Mon, 31 May 2021 12:37:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:40308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233995AbhEaOtN (ORCPT ); Mon, 31 May 2021 10:49:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 719E561466; Mon, 31 May 2021 13:56:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469408; bh=eneXgJadla0FXNynniX2GwEnmQwZmwoZoySbbR2JdRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PmYr/xhlvTsgbE0KmTZ9FvWLAiy7uhcZ+rUQu1fnFvQhzBbDNx4cA4+40c0Gr69GS sqhxx9XS/8wqvqSdSPtxnPVIpm+ccwpDwdkUDs5jJ3R648ZzCMWgcszhMQMLe0gh63 fJd6uBNXtYnkEGcXM/Jrqsgua9VEgoZH3bcZddWI= 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.12 187/296] libertas: register sysfs groups properly Date: Mon, 31 May 2021 15:14:02 +0200 Message-Id: <20210531130710.159096271@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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