aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2017-11-10 13:48:50 -0500
committerJohannes Berg <johannes.berg@intel.com>2017-11-20 10:57:15 -0500
commit67bd52386125ce1159c0581cbcd2740addf33cd4 (patch)
tree5be55da42a111f6546deb88f82030a8afdf3fbaa
parentd7be102f2945a626f55e0501e52bb31ba3e77b81 (diff)
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: ff4dd73dd2b4 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length") Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 7c3600643c7f..10b075a46b26 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -3108,6 +3108,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
3108{ 3108{
3109 struct hwsim_new_radio_params param = { 0 }; 3109 struct hwsim_new_radio_params param = { 0 };
3110 const char *hwname = NULL; 3110 const char *hwname = NULL;
3111 int ret;
3111 3112
3112 param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG]; 3113 param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG];
3113 param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE]; 3114 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)
3147 param.regd = hwsim_world_regdom_custom[idx]; 3148 param.regd = hwsim_world_regdom_custom[idx];
3148 } 3149 }
3149 3150
3150 return mac80211_hwsim_new_radio(info, &param); 3151 ret = mac80211_hwsim_new_radio(info, &param);
3152 kfree(hwname);
3153 return ret;
3151} 3154}
3152 3155
3153static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info) 3156static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)