Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp949598rwe; Fri, 26 Aug 2022 19:16:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR7MRva254vH6KlsyJRDrRtwGewbvtShr1MJziDMbMMK5Z13xpSbLGWDOhu9Jp00NTM3702I X-Received: by 2002:a62:1c8f:0:b0:537:2284:bd00 with SMTP id c137-20020a621c8f000000b005372284bd00mr6494566pfc.78.1661566613202; Fri, 26 Aug 2022 19:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661566613; cv=none; d=google.com; s=arc-20160816; b=aUfnCZrtHrzVfBZaEhgdYUPba/jACymYtqHSrSFh0dpdDgEJstzrTF4BtonUvQ3jhw bOh6MfMKsF3Zgv8g81foRu1BifpVfJLY7sJE/Tr7hcAF6lnZ5G1TunI1v9MMsvDV4JCw gYl8hO3pGQOl+XexgGtuZ26a/U1T7OnGSDM1mdxAwBTYwVn8Gz6DBTMlxFwpUXvC5lQT miszzJx/CsI/g/8WP6AEJjrEDM0rgLGinnZFzhRsUYkbT1suGvHX1altCEIsl1hgEK1b qm1KbZMKWG8pbRTXMzBK7WrhdNYHKP0fIbuBoL3PJMsdpHdfu4fg0hj2HJ1DQEWdC9aW ykbg== 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; bh=A0AgTmVQldXzT1DZn6efQa2OkzEDPvt95zoEbIxNQWo=; b=zKY7KMog2TcSet7rDE0vxAqR8QwHeD9coJEArOabKPz5al8e8ErSrECGzXYYeKynaw fgTvT2uTaEC+p3A7tHg5oRciVV0iJVO0RRJ6gBnCzgQi0FejsBNtHHyor8XKZlwfGUdW EuHASvYg3aAn93WXNjkOuva+ewSdlXgGFZKRWDGPVH53GrdFWWtVRLA1pVjDAw+WUAqs hrVVf+YefsLoEqVjyPfIy71N/T0tQ3zzqY1/GQOpo8ah22s07IaXMqrxX1ni8Tdmspvd dBqI4TOA9koJ/Ef/nM0BOjNao7u2oippcni+bDqiO3Veau4yalv+cU4QfjGgXLa4jbLV vTpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb7-20020a17090ae7c700b001fd833424a8si984826pjb.180.2022.08.26.19.16.38; Fri, 26 Aug 2022 19:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbiH0CNu (ORCPT + 64 others); Fri, 26 Aug 2022 22:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345452AbiH0CNe (ORCPT ); Fri, 26 Aug 2022 22:13:34 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 393EB1F2D9; Fri, 26 Aug 2022 19:13:33 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MF0X54W3RzkWhB; Sat, 27 Aug 2022 10:09:57 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 27 Aug 2022 10:13:31 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600010.china.huawei.com (7.193.23.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 27 Aug 2022 10:13:30 +0800 From: Sun Ke To: , , , , CC: , , , , Subject: [PATCH] mac80211: fix potential deadlock in ieee80211_key_link() Date: Sat, 27 Aug 2022 10:24:52 +0800 Message-ID: <20220827022452.823381-1-sunke32@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600010.china.huawei.com (7.193.23.86) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-wireless@vger.kernel.org Add the missing unlock before return in the error handling case. Fixes: ccdde7c74ffd ("wifi: mac80211: properly implement MLO key handling") Signed-off-by: Sun Ke --- net/mac80211/key.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/key.c b/net/mac80211/key.c index 86aac87e0211..d89ec93b243b 100644 --- a/net/mac80211/key.c +++ b/net/mac80211/key.c @@ -865,8 +865,10 @@ int ieee80211_key_link(struct ieee80211_key *key, if (link_id >= 0) { link_sta = rcu_dereference_protected(sta->link[link_id], lockdep_is_held(&sta->local->sta_mtx)); - if (!link_sta) - return -ENOLINK; + if (!link_sta) { + ret = -ENOLINK; + goto out; + } } old_key = key_mtx_dereference(sdata->local, link_sta->gtk[idx]); -- 2.31.1