qcacld-3.0: free allocated memory for failure case

When obtaining twt session traffic statistics,
some allocated memory not freed for failure case.
Fix it to avoid memory leak.

Change-Id: I18ce45467c3600c3f62b23ab50582ecb40ced88d
CRs-Fixed: 3169747
This commit is contained in:
Zhaoyang Liu
2022-04-08 12:05:06 +08:00
committed by Madan Koyyalamudi
parent 8c45c18934
commit 46d2c60297
2 changed files with 18 additions and 6 deletions

View File

@@ -4006,7 +4006,8 @@ hdd_twt_request_session_traffic_stats(struct hdd_adapter *adapter,
skb_len); skb_len);
if (!reply_skb) { if (!reply_skb) {
hdd_err("Get stats - alloc reply_skb failed"); hdd_err("Get stats - alloc reply_skb failed");
return -ENOMEM; errno = -ENOMEM;
goto free_event;
} }
status = hdd_twt_pack_get_stats_resp_nlmsg( status = hdd_twt_pack_get_stats_resp_nlmsg(
@@ -4016,14 +4017,23 @@ hdd_twt_request_session_traffic_stats(struct hdd_adapter *adapter,
event->num_twt_infra_cp_stats); event->num_twt_infra_cp_stats);
if (QDF_IS_STATUS_ERROR(status)) { if (QDF_IS_STATUS_ERROR(status)) {
hdd_err("Get stats - Failed to pack nl response"); hdd_err("Get stats - Failed to pack nl response");
wlan_cfg80211_vendor_free_skb(reply_skb); errno = qdf_status_to_os_return(status);
return qdf_status_to_os_return(status); goto free_skb;
} }
qdf_mem_free(event->twt_infra_cp_stats); qdf_mem_free(event->twt_infra_cp_stats);
qdf_mem_free(event); qdf_mem_free(event);
return wlan_cfg80211_vendor_cmd_reply(reply_skb); return wlan_cfg80211_vendor_cmd_reply(reply_skb);
free_skb:
wlan_cfg80211_vendor_free_skb(reply_skb);
free_event:
qdf_mem_free(event->twt_infra_cp_stats);
qdf_mem_free(event);
return errno;
} }
/** /**

View File

@@ -747,15 +747,15 @@ wlan_cfg80211_mc_twt_get_infra_cp_stats(struct wlan_objmgr_vdev *vdev,
out->twt_infra_cp_stats = out->twt_infra_cp_stats =
qdf_mem_malloc(sizeof(*out->twt_infra_cp_stats)); qdf_mem_malloc(sizeof(*out->twt_infra_cp_stats));
if (!out->twt_infra_cp_stats) { if (!out->twt_infra_cp_stats) {
qdf_mem_free(out);
*errno = -ENOMEM; *errno = -ENOMEM;
return NULL; return NULL;
} }
request = osif_request_alloc(&params); request = osif_request_alloc(&params);
if (!request) { if (!request) {
qdf_mem_free(out);
*errno = -ENOMEM; *errno = -ENOMEM;
return NULL; goto free_stats_event;
} }
cookie = osif_request_cookie(request); cookie = osif_request_cookie(request);
@@ -765,7 +765,7 @@ wlan_cfg80211_mc_twt_get_infra_cp_stats(struct wlan_objmgr_vdev *vdev,
qdf_mem_malloc(sizeof(*priv->twt_infra_cp_stats)); qdf_mem_malloc(sizeof(*priv->twt_infra_cp_stats));
if (!priv->twt_infra_cp_stats) { if (!priv->twt_infra_cp_stats) {
*errno = -ENOMEM; *errno = -ENOMEM;
return NULL; goto get_twt_stats_fail;
} }
twt_event = priv->twt_infra_cp_stats; twt_event = priv->twt_infra_cp_stats;
@@ -834,6 +834,8 @@ wlan_cfg80211_mc_twt_get_infra_cp_stats(struct wlan_objmgr_vdev *vdev,
get_twt_stats_fail: get_twt_stats_fail:
osif_request_put(request); osif_request_put(request);
free_stats_event:
wlan_cfg80211_mc_infra_cp_stats_free_stats_event(out); wlan_cfg80211_mc_infra_cp_stats_free_stats_event(out);
osif_debug("Exit"); osif_debug("Exit");