All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cw1200: Fix memory leak in cw1200_set_key()
@ 2022-05-26  3:30 Jianglei Nie
  2022-05-26  9:02 ` kernel test robot
  0 siblings, 1 reply; 4+ messages in thread
From: Jianglei Nie @ 2022-05-26  3:30 UTC (permalink / raw)
  To: pizza, kvalo, davem, edumazet, kuba, pabeni
  Cc: linux-wireless, netdev, linux-kernel, Jianglei Nie

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-27  6:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  3:30 [PATCH] cw1200: Fix memory leak in cw1200_set_key() Jianglei Nie
2022-05-26  9:02 ` kernel test robot
2022-05-27  6:27   ` Kalle Valo
2022-05-27  6:27     ` Kalle Valo

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.