From patchwork Sat Aug 27 02:24:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sun Ke X-Patchwork-Id: 600710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEAE6ECAAD4 for ; Sat, 27 Aug 2022 02:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231629AbiH0CNu (ORCPT ); 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 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 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]);