Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp593063ioo; Thu, 26 May 2022 10:05:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+kHNphnpQrnZGbHXFXNPMlVWLIXPd1x8tDbN3/UiDzkoCGkqSpinDXEfHMoRetlFIUUc/ X-Received: by 2002:a17:902:dad1:b0:161:a747:f962 with SMTP id q17-20020a170902dad100b00161a747f962mr39380670plx.32.1653584756980; Thu, 26 May 2022 10:05:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653584756; cv=none; d=google.com; s=arc-20160816; b=qhfH/1QXNMqs+f58xA2F8u9U1gUuueTw8DYElhOTGzNiYAcnGsl49vZi7Xha1KZAq1 phGATstApZhhtwq9xOSQhSDH2Lu0Djzb1HSPX2lMihDh6YnQAE9FrzIyv6RPAbR6blrb zLC3pnSpdq7EQLrsZ52OQ7/Ev8Pzx8b+GIb0jRyvmuaSNxTX1vmV4wYKXKo55/QzJ+t7 7WvJ4p+83P3VZIdTTm2KYFWTeqIhHxTc97dsh22Xim6uyFgSwLhMu2jpHUFoOj9gy5ph 47uxl7EqABGrTh0UJmhgDQUyh6tWeBf4YofQtskRjwbtV8eSGMT937W3m8wA5sCL9r9L YLZg== 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=CjTO1zV1XxDBvRyik+WBGvUIZFFmgjo+eyQguphswZA=; b=Mql7UAeGRaoLgSGbRvhQi/j7aEShXNCFfssfmpmGaswTbyx6FbqaClj00ONXJh477a kT9iYpMXfclW2mCa9/3RPJgDUM7qDk/yj3Tgt4IbotdvnuCEOYDSgUlV8SLCEZgVdbtK jEg998KGfQbnqv1Px4fYubX20W05a0nVte4Nger4dCHgd9fF3lLv09cmUsUpf9On06vK htErf1OKW3jIzYDN1Y/LgR1gX4A2K5RrAE9OFWLRNjiXgr67qO69Cng4jL+u1oS56UyU IdEpzMcrfz8iHc2qzbPwZtjLrKnWUG9jIoD2CeBn4l/03JhATZ8SLBBgJsFJG6jek8kP Xiaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=fwlLaKzW; 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=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb14-20020a170903258e00b00161ff6a4022si2250124plb.338.2022.05.26.10.05.43; Thu, 26 May 2022 10:05:56 -0700 (PDT) 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=@163.com header.s=s110527 header.b=fwlLaKzW; 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=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244415AbiEZDqC (ORCPT + 99 others); Wed, 25 May 2022 23:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231163AbiEZDqA (ORCPT ); Wed, 25 May 2022 23:46:00 -0400 X-Greylist: delayed 914 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 25 May 2022 20:45:58 PDT Received: from mail-m973.mail.163.com (mail-m973.mail.163.com [123.126.97.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 785C735DD7; Wed, 25 May 2022 20:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=CjTO1 zV1XxDBvRyik+WBGvUIZFFmgjo+eyQguphswZA=; b=fwlLaKzWVMM5dd12lo4e8 A/aAWpMLYTUCF86JRTQhpTcpd0yzeVoDKDXqncr1tSbACKnZ+WU0HdwscDV36A8B TXTHxCPw/Vh1ZT/RL7zhK6u0NmS544WTPCH9K67cGz44dNfcseaB6MZY+P/lr6UV 860oL8uw3R41TWTeWuwnPA= Received: from localhost.localdomain (unknown [123.112.69.106]) by smtp3 (Coremail) with SMTP id G9xpCgA3f6s89I5iG2uqEg--.14753S4; Thu, 26 May 2022 11:30:14 +0800 (CST) From: Jianglei Nie To: pizza@shaftnet.org, kvalo@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] cw1200: Fix memory leak in cw1200_set_key() Date: Thu, 26 May 2022 11:30:03 +0800 Message-Id: <20220526033003.473943-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: G9xpCgA3f6s89I5iG2uqEg--.14753S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jr18Aw1rCF4DKFW7Cr4fuFg_yoW3KFX_GF 1Yqa18Grs7Jr12kryrAr4furWSv3WYgF4fuay2qayayanrurWDXr15XFWxJryUK3y8ZF4f Gw4kWa1rAw1jqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xREsjjJUUUUU== X-Originating-IP: [123.112.69.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiWwcNjGI0Up-XlwABsH X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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-kernel@vger.kernel.org When wsm_key.index > WSM_KEY_MAX_INDEX, cw1200_set_key() returns without calling cw1200_free_key() like other wrong paths, which may lead to a potential memory leak. We can fix it by calling cw1200_free_key() when some error occurs. Signed-off-by: Jianglei Nie --- drivers/net/wireless/st/cw1200/sta.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/st/cw1200/sta.c b/drivers/net/wireless/st/cw1200/sta.c index 236022d4ae2a..c0097577978d 100644 --- a/drivers/net/wireless/st/cw1200/sta.c +++ b/drivers/net/wireless/st/cw1200/sta.c @@ -823,6 +823,7 @@ int cw1200_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, }; if (wsm_key.index > WSM_KEY_MAX_INDEX) { + cw1200_free_key(priv, idx); ret = -EINVAL; goto finally; } -- 2.25.1