mac80211_hwsim: fix memory leak in hwsim_new_radio_nl
authorZhengchao Shao <shaozhengchao@huawei.com>
Mon, 15 May 2023 09:22:27 +0000 (17:22 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 16 May 2023 17:29:34 +0000 (10:29 -0700)
When parse_pmsr_capa failed in hwsim_new_radio_nl, the memory resources
applied for by pmsr_capa are not released. Add release processing to the
incorrect path.

Fixes: 92d13386ec55 ("mac80211_hwsim: add PMSR capability support")
Reported-by: syzbot+904ce6fbb38532d9795c@syzkaller.appspotmail.com
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230515092227.2691437-1-shaozhengchao@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/virtual/mac80211_hwsim.c

index 9a8faaf..89c7a14 100644 (file)
@@ -5964,10 +5964,11 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
                        ret = -ENOMEM;
                        goto out_free;
                }
+               param.pmsr_capa = pmsr_capa;
+
                ret = parse_pmsr_capa(info->attrs[HWSIM_ATTR_PMSR_SUPPORT], pmsr_capa, info);
                if (ret)
                        goto out_free;
-               param.pmsr_capa = pmsr_capa;
        }
 
        ret = mac80211_hwsim_new_radio(info, &param);