Skip to content

Commit 0ddcff4

Browse files
weiyongjun (A)jmberg-intel
weiyongjun (A)
authored andcommitted
mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl()
'hwname' is malloced in hwsim_new_radio_nl() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: ff4dd73 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 9cb05f9 commit 0ddcff4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: drivers/net/wireless/mac80211_hwsim.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -3197,8 +3197,10 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
31973197
if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) {
31983198
u32 idx = nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]);
31993199

3200-
if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom))
3200+
if (idx >= ARRAY_SIZE(hwsim_world_regdom_custom)) {
3201+
kfree(hwname);
32013202
return -EINVAL;
3203+
}
32023204
param.regd = hwsim_world_regdom_custom[idx];
32033205
}
32043206

0 commit comments

Comments
 (0)