Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp493699lqb; Wed, 17 Apr 2024 02:35:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWw7WTmdk3fc85iJmEQD21+YVqPqtzq0LuOJF+adboev7bPAU9ygr0od/rMBWTnJNT/MB2Itp28UdY8ChjV45lekvE5OcjvwFpCGRLBJA== X-Google-Smtp-Source: AGHT+IFpjpj2ANW/14fGINl8PxBVOWrkQTV1P3fRC1bzoMxjfpmZFWFwVU9thSMPcQvkAhfrnOyS X-Received: by 2002:a17:907:9309:b0:a55:5520:f43f with SMTP id bu9-20020a170907930900b00a555520f43fmr1574402ejc.10.1713346501943; Wed, 17 Apr 2024 02:35:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713346501; cv=pass; d=google.com; s=arc-20160816; b=NXryFqbBJlzbjiOd2eIKJZZqH72JTQcL2Q6wQaLN4srqCSyxLeJQW8pvbl7N9nOFoz GYXrRuO42ziRv/VMT3OF+aJIoapzm3g/Yzc8ABwipDUQMM5KE91X8xiJuRydOJnDeg8n AXcNZnHLShFnaRIykFEXk/iQWpvFggpXt+eOXYZc41smn9NglHRaGRJ1rE5DyZxUpHhQ PlwwadhgD9Bp4g6a9bMCpLyI6vUNCN6gG/oqkjmmKq0Ezy8nP3fV9RPeuHD5oDdpCyRg L6XeiNHJ9kHgZlQeptFiBJ2dERZPxChCIXR/tlxUGK1aa461f/Y3F/Jt5D1v62Ecagp7 X7Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=UL/FZYt1ZDeYd7vr1TRXKJow8zuiDeZ1OlrlaoQyJrs=; fh=k15yWD4ZltoIGsKlbGcsGeIaHes0BFY8NEK3tQ/9pa0=; b=eMkyJG6bcbg2rfyhHmcZHX6/DZSVhscsEypXmWcl5sCR6JPGbWtf/wz7dg62HPjCG8 IzHiqpn0qo1YiiPzT5iFU1KCCDyL5/qEmibjIlQkot6idcGbe9E7fj/nPsRHJDeRxB+M p3L5kByQQvE7AyEDiZhHY9WQLReBOTTZfpzmVlYropIOOyPO26913o2P4S9rqIAkrqFx jP+Fk4EkysD9lWOnR/tMaYTUacy8caX83TLPaaP62DDhopvVGY/+Pv3h4WQzL8tK5jac is5fpMjkNqJZ2uzVQdJtInb4KqPhLfofZK/3B5GHx5DfpdGBAZ9376Y3yT+SJftUfkPm xhxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KIaMesHn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-wireless+bounces-6434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h24-20020a50cdd8000000b0056dfa65446fsi6565436edj.362.2024.04.17.02.35.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KIaMesHn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-wireless+bounces-6434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4BD9C1F22A85 for ; Wed, 17 Apr 2024 09:35:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DA6C13AD15; Wed, 17 Apr 2024 09:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KIaMesHn" X-Original-To: linux-wireless@vger.kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B96B13A885; Wed, 17 Apr 2024 09:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346464; cv=none; b=lUcsV1WiW8zJjCtw09HPRfuocCkkRB7Lsge7bCpi3dHyZANY+awbB974O9yxS3KODtMwx7o6oqC05G6xpRYtOfPN1mnZinhXxIkcNfp/Y0CMwP+/xBZ77SRmgv/s8/xLbls1qKLoaVpPOMK5jUgjiJzyX5bIvuXYforVkjN6CDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346464; c=relaxed/simple; bh=0/ADeysUK6zcQEDcTdDJA5QqOa1mNX4iXTZev0jcyPI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dCOd9bOcCbcQyyJ8k+qG0hAvlijrP6I4QKcNxph7jm/6Rjqxo4GJExAvHQiZMuZdl/reGq2daY89/bpVlJpn6jtu/ayvxqs3R7ZZuQ/xhe0AJodXWqdoPh3AeB3EPylbdwB729IBBW6SmPSPUA+mHmicaUfkK88pF+NlkKNGUas= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KIaMesHn; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 75E42FF806; Wed, 17 Apr 2024 09:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713346454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UL/FZYt1ZDeYd7vr1TRXKJow8zuiDeZ1OlrlaoQyJrs=; b=KIaMesHnGM+QZ4HHU+SLtct92NVgLJLR6l+r128sCBRTosp72UH9pOBFMOO22BJeyGPdnf FfOml01VsVpwSjwFRv8Y8BBOhTXD9dPOsTrfIa3/YKWSPj9owJz/CjFa0a4/kR1xdCtAcL lsHmj0RXhsvlx2VDKsh8fDuND0RZnLyl48kqj3cDkCkjCuMi76Kt2fkpfZdsXD+urP9aT1 wGlRbnWGxxBbKJlp7niM2zwjmHICVggzuZcR6Mk6APS/6AuyrlCvnvHISxH0C9TPmzpkmw OTFbMV7EmXaABE4CP4gh+5qR8JnNy5CUKUap3jKSANk54vHdRHP4TKXk82TE/A== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Wed, 17 Apr 2024 11:34:08 +0200 Subject: [PATCH 1/6] wifi: wilc1000: set net device registration as last step during interface creation Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240417-mac_addr_at_probe-v1-1-67d6c9b3bc2b@bootlin.com> References: <20240417-mac_addr_at_probe-v1-0-67d6c9b3bc2b@bootlin.com> In-Reply-To: <20240417-mac_addr_at_probe-v1-0-67d6c9b3bc2b@bootlin.com> To: Ajay Singh , Claudiu Beznea , Kalle Valo Cc: Thomas Petazzoni , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com net device registration is currently done in wilc_netdev_ifc_init but other initialization operations are still done after this registration. Since net device is assumed to be usable right after registration, it should be the very last step of initialization. Move netdev registration at the very end of wilc_netdev_ifc_init to let this function completely initialize netdevice before registering it. Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/netdev.c | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 73f56f7b002b..acc9b9a64552 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -965,16 +965,6 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, vif->priv.wdev.iftype = type; vif->priv.dev = ndev; - if (rtnl_locked) - ret = cfg80211_register_netdevice(ndev); - else - ret = register_netdev(ndev); - - if (ret) { - ret = -EFAULT; - goto error; - } - ndev->needs_free_netdev = true; vif->iftype = vif_type; vif->idx = wilc_get_available_idx(wl); @@ -985,13 +975,24 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, mutex_unlock(&wl->vif_mutex); synchronize_rcu(); - return vif; - -error: if (rtnl_locked) - cfg80211_unregister_netdevice(ndev); + ret = cfg80211_register_netdevice(ndev); else - unregister_netdev(ndev); + ret = register_netdev(ndev); + + if (ret) { + ret = -EFAULT; + goto error_remove_vif; + } + + return vif; + +error_remove_vif: + mutex_lock(&wl->vif_mutex); + list_del_rcu(&vif->list); + wl->vif_num -= 1; + mutex_unlock(&wl->vif_mutex); + synchronize_rcu(); free_netdev(ndev); return ERR_PTR(ret); } -- 2.44.0