All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jianglei Nie <niejianglei2021@163.com>
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 <niejianglei2021@163.com>
Subject: [PATCH] cw1200: Fix memory leak in cw1200_set_key()
Date: Thu, 26 May 2022 11:30:03 +0800	[thread overview]
Message-ID: <20220526033003.473943-1-niejianglei2021@163.com> (raw)

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 <niejianglei2021@163.com>
---
 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


             reply	other threads:[~2022-05-26  3:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26  3:30 Jianglei Nie [this message]
2022-05-26  9:02 ` [PATCH] cw1200: Fix memory leak in cw1200_set_key() kernel test robot
2022-05-27  6:27   ` Kalle Valo
2022-05-27  6:27     ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220526033003.473943-1-niejianglei2021@163.com \
    --to=niejianglei2021@163.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pizza@shaftnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.