Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2704702pxy; Mon, 3 May 2021 06:18:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+eh7kxiHaPe1hkr4eueD1QMKmLUQC3j8v8hKhnLplpO9ZzfPES6ITC0+C0ZO+rgWsha0z X-Received: by 2002:a17:902:9a87:b029:ed:ea18:b2f3 with SMTP id w7-20020a1709029a87b02900edea18b2f3mr19912831plp.69.1620047893921; Mon, 03 May 2021 06:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620047893; cv=none; d=google.com; s=arc-20160816; b=jCEvSv3znofWX0FIccYhQ9CYz1+gtjnftQV4g4cISyq5hOOAPST6VmNFCgUPJPWaqZ /GmvhzyRuDz3BrSaZoUwO1ZFW12UnFSWv7FqOUpWKe5yHxbFnioF0aA5HhQ2yUuYMTZo H58a26phLVQHZMkupxLvt+DQxKjDDOO7mlf3HZ9hCYVLMvaqYyhj7MOXEvkjqTtMbhV+ 7cyqC4cha0nAurzqL9A8H9VSnCrLulJ7+WYRB/vermaqTWrBW6pRfDNnQ57lYtyND32y 56Ukw4Xmu6uBr0rurVj4wrzC1l7LA36djtcVWNbQ4/Dku8udPaCUxMH/UtWdlNwrGt5u 5r2A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xGckRPV+cE3dXwasOqNWBUl+Le37RXiZ15LibHmaEfk=; b=sCQwbBtLCEnDt0RFLi0vogA/9eYRsH+jzD/L+o0kL4rx1XJzk0rahFJq+XGC4gyy2p J6jaypR74OHMxwCFj5O/tR9GprkOhXj0ZUEXyth3jecISiL4i5QguubATsYw0rZWXknr X0OC9Cf+Bt0uqOEA1/lge/HjDiG7GTHOeonnVw2omULcOVUXwo0P1GNg89OlRwXpjQdC +jaQ3Mo2chvt5h/uNdvqHm8AucKDKCISUI35U30Bg4y1EBiNUBHsyY3D5Bn36WABDMp+ X+lfBBSvQIrIPCRkLCv/2bSybZJtKHZUqmIcrYfswT5V+wOHZ4Ki4N+jHrQcewhg0akM YaHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SpzuOlzl; 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 t5si12417448pgk.379.2021.05.03.06.18.01; Mon, 03 May 2021 06:18:13 -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=SpzuOlzl; 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 S234131AbhECMCU (ORCPT + 99 others); Mon, 3 May 2021 08:02:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233841AbhECMBa (ORCPT ); Mon, 3 May 2021 08:01:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7E1656135F; Mon, 3 May 2021 12:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043237; bh=65SYmV8eC6AkhyxvGxcpDbHqc9+CuujVGcrZpPUegOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SpzuOlzlwKXupkcNpyC1wJKbW5HCpJYfjj6FnJe/471Et2s/4InzaX3mg+cMEA7L4 K95oMBzJC8ITL86hOIFb6Nyff3btqe/9paKoioPdAT0+MURJrKdBuV5iiRQtGCCfkJ iju1ZXPDIvclr1NcmIpjpe9JOCzsrH8MyYIDVE1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Kalle Valo Subject: [PATCH 53/69] libertas: register sysfs groups properly Date: Mon, 3 May 2021 13:57:20 +0200 Message-Id: <20210503115736.2104747-54-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Greg Kroah-Hartman --- 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.31.1