Skip to content

Commit 67bd523

Browse files
bwh-ctjmberg-intel
authored andcommitted
mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl()
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]>
1 parent d7be102 commit 67bd523

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/net/wireless/mac80211_hwsim.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3108,6 +3108,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
31083108
{
31093109
struct hwsim_new_radio_params param = { 0 };
31103110
const char *hwname = NULL;
3111+
int ret;
31113112

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

3150-
return mac80211_hwsim_new_radio(info, &param);
3151+
ret = mac80211_hwsim_new_radio(info, &param);
3152+
kfree(hwname);
3153+
return ret;
31513154
}
31523155

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

0 commit comments

Comments
 (0)