* [PATCH] mwifiex: Fix mem leak in mwifiex_tm_cmd
@ 2019-03-12 7:03 Yue Haibing
2019-04-04 10:19 ` Kalle Valo
0 siblings, 1 reply; 2+ messages in thread
From: Yue Haibing @ 2019-03-12 7:03 UTC (permalink / raw)
To: amitkarwar, nishants, gbhat, huxinming820, kvalo, davem
Cc: linux-kernel, netdev, linux-wireless, YueHaibing
From: YueHaibing <yuehaibing@huawei.com>
'hostcmd' is alloced by kzalloc, should be freed before
leaving from the error handling cases, otherwise it will
cause mem leak.
Fixes: 3935ccc14d2c ("mwifiex: add cfg80211 testmode support")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/net/wireless/marvell/mwifiex/cfg80211.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index c46f0a5..e582d9b 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -4082,16 +4082,20 @@ static int mwifiex_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
if (mwifiex_send_cmd(priv, 0, 0, 0, hostcmd, true)) {
dev_err(priv->adapter->dev, "Failed to process hostcmd\n");
+ kfree(hostcmd);
return -EFAULT;
}
/* process hostcmd response*/
skb = cfg80211_testmode_alloc_reply_skb(wiphy, hostcmd->len);
- if (!skb)
+ if (!skb) {
+ kfree(hostcmd);
return -ENOMEM;
+ }
err = nla_put(skb, MWIFIEX_TM_ATTR_DATA,
hostcmd->len, hostcmd->cmd);
if (err) {
+ kfree(hostcmd);
kfree_skb(skb);
return -EMSGSIZE;
}
--
2.7.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mwifiex: Fix mem leak in mwifiex_tm_cmd
2019-03-12 7:03 [PATCH] mwifiex: Fix mem leak in mwifiex_tm_cmd Yue Haibing
@ 2019-04-04 10:19 ` Kalle Valo
0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-04-04 10:19 UTC (permalink / raw)
To: Yue Haibing
Cc: amitkarwar, nishants, gbhat, huxinming820, davem, linux-kernel,
netdev, linux-wireless, YueHaibing
Yue Haibing <yuehaibing@huawei.com> wrote:
> From: YueHaibing <yuehaibing@huawei.com>
>
> 'hostcmd' is alloced by kzalloc, should be freed before
> leaving from the error handling cases, otherwise it will
> cause mem leak.
>
> Fixes: 3935ccc14d2c ("mwifiex: add cfg80211 testmode support")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Patch applied to wireless-drivers-next.git, thanks.
003b686ace82 mwifiex: Fix mem leak in mwifiex_tm_cmd
--
https://patchwork.kernel.org/patch/10848633/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-04 10:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12 7:03 [PATCH] mwifiex: Fix mem leak in mwifiex_tm_cmd Yue Haibing
2019-04-04 10:19 ` Kalle Valo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).