Skip to content

Commit

Permalink
cw1200: Fix memory leak in cw1200_set_key()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jianglei Nie authored and intel-lab-lkp committed May 26, 2022
1 parent 805cb5a commit 1e40283
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/st/cw1200/sta.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1e40283

Please sign in to comment.