From patchwork Thu Feb 9 22:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 55114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp610975wrn; Thu, 9 Feb 2023 14:32:57 -0800 (PST) X-Google-Smtp-Source: AK7set8K8fJ6RNyCK0l/VAr6ZZVfNkYIoYZlOp3Z1VXrII4iRGdEsNq48YrNRHtvXvYTE4+Wdd3G X-Received: by 2002:a05:6402:2989:b0:4aa:cf80:44af with SMTP id eq9-20020a056402298900b004aacf8044afmr8644367edb.7.1675981977033; Thu, 09 Feb 2023 14:32:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675981977; cv=none; d=google.com; s=arc-20160816; b=y8rPP4r2VNbxOmVz5BVzbkP5BT17rOilh7islnM0JUC5iSXEaSF/a8QiT45X5s/KP1 p4yBNwuEHWDCGNhI1ICDQmkymo4Jap5QBmC7q0B2DNjVH9WZ8p3MSZgxvUovvwLZDO5z kvFt/Wh9Krr9GVi9o2Xc0VCC6rQphgjS8ATcnD/1JO1B+cLqxZpqKoBtZUcJk8KD9iYA H1PUypqxFQPVcEncIxMdvgAPip7E2GFSf8fyrPV0A6CbnQkNOGHOGDvAxDol9SaX2aRK Ut3kpi9PNguNCs2LyGgT0RTfjJsXCKGCScMFG7/5R2KGHHp1sX9qy8gszMBeyJzCUeo/ vQtw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=mA+W2iIOZyTuxfiY1E6tdbEkL6JPb15N04qIIGKc1Bo=; b=Y0lxiCGegIAduG+t97UPeuFEj605WDdlPj1r4ntiiy/hicTUWTu+95GvtHni21yPT7 lfNPyyZTrFKFTz5E9NW5dLZb4NrB+fvnER+xCRQkU5TKrVM8OlUd1PzTXsbZBXYBZzK9 +P+OybiyYmdVZxNLKEsqE41sIJBaH1mhgzETnqhFtSL9TrFWr1jcPm11ysssQvpZBlG/ SGSmlVvJuT4mF+bOKFyACeIJtIXUV96fN/LkUbzNjLd2dG9QHQ5lw7r/EShc/Mi4S32D id4FeuZXVHhcEDftM0MIT0pdVjuH9Sn2APKCKYHFgP65EkGO8kBbcAk3DpWtlcJbS1/O Hyug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=grXmBtKi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020aa7dad8000000b004ab1d672074si3375071eds.167.2023.02.09.14.32.29; Thu, 09 Feb 2023 14:32:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=grXmBtKi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230296AbjBIW1I (ORCPT + 99 others); Thu, 9 Feb 2023 17:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbjBIW1G (ORCPT ); Thu, 9 Feb 2023 17:27:06 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC8A266EE4; Thu, 9 Feb 2023 14:27:03 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so5023665wma.1; Thu, 09 Feb 2023 14:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mA+W2iIOZyTuxfiY1E6tdbEkL6JPb15N04qIIGKc1Bo=; b=grXmBtKibLp67pM4ScaLs8kExZlNValb1oKoIp5YGcr5Ka8i5Vst+TIefQJ5MpCB2K VpPw/jCAfXG9qHDSmBCEXEsY5abPFUomHZoUOkjAhusUsT0KWs/mRzHw/Bjytfo2xvqB 35I0J8FA2XqUPrUh/JwRiZql3tU04aw8cu907PJbOcyPSxWYifpN076p3fVwKC+9GZCs XsavH/GYiGWIL+sOHCxOTYP9yRpJGezm2MWtd9+01hSuQ+dWDRs+OPRkXZoixrYwbeNd Okax6wTuJMxGGj1Rhvi+8GnzIctYs5qdmDjNexCH6XjlPTSe915zwj5iqq9V8luXkvb5 7nQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mA+W2iIOZyTuxfiY1E6tdbEkL6JPb15N04qIIGKc1Bo=; b=UIbVfPxtG2v4nsjCfjzTFLwP2SP1sXFVf/H9RmQc7sv85d008WCe7bDK/iG+d/rqNE XWXyu3d6vzetyppbeCsEsUkgnHsMuy/a+i2ujsumfi63EELZLZ7utACdnbU0g//EV6ci pr5Sd8kBU7x6fGj5IQWoSqKLqw+D0B0onktnBOMLLGUd856qDvuHyqgrfU0W4XBLrwG6 X3pcvKR20C2naBM0XmEmBMElxOn6dgPIEYQPbmtOdcjFyZJbB0warE0JHUU2rqkdA+Sl K9DJzgjPHoC95kRGZz9CyrIrx2MuLkcQSCleh0YwLEsBDRbWk73QhcYtjkkMvIg79I83 AzBg== X-Gm-Message-State: AO0yUKULeYFjA/39SyjuPWtEsYag8CfgNECu16V9mIMNeFabuaceau3n E3UNBI8fJ8YtEfqZ/IU98udpT6CWH34= X-Received: by 2002:a05:600c:45cf:b0:3df:9858:c03c with SMTP id s15-20020a05600c45cf00b003df9858c03cmr7827388wmo.17.1675981622191; Thu, 09 Feb 2023 14:27:02 -0800 (PST) Received: from localhost.localdomain (93-34-91-73.ip49.fastwebnet.it. [93.34.91.73]) by smtp.googlemail.com with ESMTPSA id l40-20020a05600c1d2800b003dd1b00bd9asm3573030wms.32.2023.02.09.14.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 14:27:01 -0800 (PST) From: Christian Marangi To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Marangi , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dan Carpenter Subject: [PATCH] wifi: ath11k: fix SAC bug on peer addition with sta band migration Date: Thu, 9 Feb 2023 23:26:22 +0100 Message-Id: <20230209222622.1751-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757394477280718379?= X-GMAIL-MSGID: =?utf-8?q?1757394477280718379?= Fix sleep in atomic context warning detected by Smatch static checker analyzer. Following the locking pattern for peer_rhash_add lock tbl_mtx_lock mutex always even if sta is not transitioning to another band. This is peer_add function and a more secure locking should not cause performance regression. Fixes: d673cb6fe6c0 ("wifi: ath11k: fix peer addition/deletion error on sta band migration") Reported-by: Dan Carpenter Signed-off-by: Christian Marangi --- drivers/net/wireless/ath/ath11k/peer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/peer.c b/drivers/net/wireless/ath/ath11k/peer.c index 1ae7af02c364..1380811827a8 100644 --- a/drivers/net/wireless/ath/ath11k/peer.c +++ b/drivers/net/wireless/ath/ath11k/peer.c @@ -382,22 +382,23 @@ int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif, return -ENOBUFS; } + mutex_lock(&ar->ab->tbl_mtx_lock); spin_lock_bh(&ar->ab->base_lock); peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr); if (peer) { if (peer->vdev_id == param->vdev_id) { spin_unlock_bh(&ar->ab->base_lock); + mutex_unlock(&ar->ab->tbl_mtx_lock); return -EINVAL; } /* Assume sta is transitioning to another band. * Remove here the peer from rhash. */ - mutex_lock(&ar->ab->tbl_mtx_lock); ath11k_peer_rhash_delete(ar->ab, peer); - mutex_unlock(&ar->ab->tbl_mtx_lock); } spin_unlock_bh(&ar->ab->base_lock); + mutex_unlock(&ar->ab->tbl_mtx_lock); ret = ath11k_wmi_send_peer_create_cmd(ar, param); if (ret) {