mac80211_hwsim: fix a possible memory leak in hwsim_new_radio_nl()
authorYueHaibing <yuehaibing@huawei.com>
Tue, 24 Apr 2018 03:08:35 +0000 (11:08 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 7 May 2018 13:01:29 +0000 (15:01 +0200)
'hwname' should be freed before leaving from the error handling cases,
otherwise it will cause mem leak

Fixes: cb1a5bae5684 ("mac80211_hwsim: add permanent mac address option for new radios")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/mac80211_hwsim.c

index 96d26cf..4a017a0 100644 (file)
@@ -3236,6 +3236,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
                        GENL_SET_ERR_MSG(info,"MAC is no valid source addr");
                        NL_SET_BAD_ATTR(info->extack,
                                        info->attrs[HWSIM_ATTR_PERM_ADDR]);
+                       kfree(hwname);
                        return -EINVAL;
                }