Skip to content

Commit

Permalink
mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl()
Browse files Browse the repository at this point in the history
hwsim_new_radio_nl() now copies the name attribute in order to add a
null-terminator.  mac80211_hwsim_new_radio() (indirectly) copies it
again into the net_device structure, so the first copy is not used or
freed later.  Free the first copy before returning.

Fixes: ff4dd73 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length")
Signed-off-by: Ben Hutchings <[email protected]>
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
bwh-ct authored and jmberg-intel committed Nov 20, 2017
1 parent d7be102 commit 67bd523
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -3108,6 +3108,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
{
struct hwsim_new_radio_params param = { 0 };
const char *hwname = NULL;
int ret;

param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG];
param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE];
Expand Down Expand Up @@ -3147,7 +3148,9 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
param.regd = hwsim_world_regdom_custom[idx];
}

return mac80211_hwsim_new_radio(info, &param);
ret = mac80211_hwsim_new_radio(info, &param);
kfree(hwname);
return ret;
}

static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)
Expand Down

0 comments on commit 67bd523

Please sign in to comment.