Skip to content

Commit 0ddcff4

Browse files
weiyongjun (A)jmberg-intel
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 <[email protected]> Reviewed-by: Ben Hutchings <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 9cb05f9 commit 0ddcff4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 3 additions & 1 deletion
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)