Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2623828pxj; Mon, 31 May 2021 06:49:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweK4QaC5wMmzJ/BUHoIODR/hkO72YmL1+PBkJXW+lT3SIBJJhvf0VvUHh/ZKbqK42z+eKx X-Received: by 2002:a05:6e02:1a6a:: with SMTP id w10mr2408094ilv.130.1622468972063; Mon, 31 May 2021 06:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622468972; cv=none; d=google.com; s=arc-20160816; b=B2RIaSy9A4hTojV5lxFg4R9LDnJfc6daSLWJAfMKOB8oF0fmwn8eaYO6IaMOQ1y8+q 3zgJqnPTlqQzcx1UY45irFF4dqkyXotpaxT9W13KA4VBjm6pvuftkE3Z7dBgVyhoC3fp WFhcf3W8IUg0q/NrPzW1JXPEThtpmRJzpl2P6kswJ3tFabGVgEkNnp2IhQvA4j1OHPpz 2yB91TOPq17bzwoAyk246wAlEAnSGP0SMGkkZkBnzbY3rjl7IrbDGHI8+6o1LiO/XrEc ok+q105ly66LI34Uilzrtnbjd3mvueeBzm3977vfa8cKDwwfC3z4QTONhfHH5z2rDzfI KOpQ== 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=Uz/1hwksZqeevtJbW8SjcfuqHApbJVjdq+8I55BBrd4=; b=WCjFGM/ozLECEqL0uL8ssdbOb5Y0eKvL8u7JcQ6QNejWDhxD85uc3lcbRb9R3gJuV+ /1mpkUXqog6dQsV4h1TIWnQiMmTYAhWD6Kq8+SVHiA8X2kp6TDX61yWH3IxF6vPhNCpw ZQmPshbA6RluI2+ynFQkqgeDVItpM3oZuXd0lnz/PT1/1KN5U9thfd4t69VcrJjDQ3C4 DGwx/7P/8X/XuwMT0afiy5qYmHc8XlzlV74UCzMs+DSGGZ+0l0Jl6kvdc2KPUpeZd3l8 brRr3lt0CjLSwETDU7ycFUVYB5//akGqWycA4TBZA+wyjCf7ETI3Xbc/NUs1+UCWFfBx 0tjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NTJlJ2Ti; 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 p31si16130158jac.95.2021.05.31.06.49.18; Mon, 31 May 2021 06:49:32 -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=NTJlJ2Ti; 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 S232523AbhEaNsb (ORCPT + 99 others); Mon, 31 May 2021 09:48:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:39376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbhEaNdd (ORCPT ); Mon, 31 May 2021 09:33:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6ABE61437; Mon, 31 May 2021 13:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467483; bh=GQydZjDT4wPdUn9WToJFxN5ZGS2Al09Z1XjGbD6BL0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NTJlJ2TiPozxSxoC0aD0gOnBmi9Szo+sxJ/CIXijZLxU+a0Xmrivr+tFnGH9f7ap3 knzlQxHgEpIqxnq8xuryWnbTsf3aWFtmVf8Calfts1BN8TxIh8JId5Y3+gl+DPfa9X P8wCdCPFSD27nZxX2YoHise0ATshXAlTh2n/JzEk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kalle Valo , Sasha Levin Subject: [PATCH 4.19 083/116] libertas: register sysfs groups properly Date: Mon, 31 May 2021 15:14:19 +0200 Message-Id: <20210531130642.970757917@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 b0cb16ef8d1d..b313c78e2154 100644 --- a/drivers/net/wireless/marvell/libertas/mesh.c +++ b/drivers/net/wireless/marvell/libertas/mesh.c @@ -793,19 +793,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 @@ -1005,6 +992,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) { @@ -1012,19 +1003,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); @@ -1045,8 +1027,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