qcacld-3.0: reduce stack frame size for __wlan_hdd_cfg80211_get_wifi_info

Encountered build failure as below:
error: stack frame size (2480) exceeds limit (2048) in
'wlan_hdd_cfg80211_get_wifi_info' [-Werror,-Wframe-larger-than]

To fix it, allocate the buffer for firmware version dynamically.

Change-Id: If768d4eccf5c6e85735c3bf3afaaf47759f0d40e
CRs-Fixed: 3343984
This commit is contained in:
Yu Wang
2022-11-23 12:18:43 +08:00
committed by Madan Koyyalamudi
parent 07dcce718b
commit 3e2d8bbb7d

View File

@@ -7252,8 +7252,7 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
{ {
struct hdd_context *hdd_ctx = wiphy_priv(wiphy); struct hdd_context *hdd_ctx = wiphy_priv(wiphy);
struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1]; struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_GET_MAX + 1];
tSirVersionString driver_version; uint8_t *firmware_version = NULL;
tSirVersionString firmware_version;
int status; int status;
struct sk_buff *reply_skb; struct sk_buff *reply_skb;
uint32_t skb_len = 0, count = 0; uint32_t skb_len = 0, count = 0;
@@ -7281,9 +7280,7 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
hdd_debug("Rcvd req for Driver version"); hdd_debug("Rcvd req for Driver version");
strlcpy(driver_version, QWLAN_VERSIONSTR, skb_len += strlen(QWLAN_VERSIONSTR) + 1;
sizeof(driver_version));
skb_len += strlen(driver_version) + 1;
count++; count++;
} }
@@ -7292,16 +7289,20 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
if (!pld_get_soc_info(hdd_ctx->parent_dev, &info)) if (!pld_get_soc_info(hdd_ctx->parent_dev, &info))
stt_flag = true; stt_flag = true;
snprintf(firmware_version, sizeof(firmware_version), firmware_version = qdf_mem_malloc(SIR_VERSION_STRING_LEN);
"FW:%d.%d.%d.%d.%d.%d HW:%s STT:%s", if (!firmware_version)
hdd_ctx->fw_version_info.major_spid, return -ENOMEM;
hdd_ctx->fw_version_info.minor_spid,
hdd_ctx->fw_version_info.siid, snprintf(firmware_version, SIR_VERSION_STRING_LEN,
hdd_ctx->fw_version_info.rel_id, "FW:%d.%d.%d.%d.%d.%d HW:%s STT:%s",
hdd_ctx->fw_version_info.crmid, hdd_ctx->fw_version_info.major_spid,
hdd_ctx->fw_version_info.sub_id, hdd_ctx->fw_version_info.minor_spid,
hdd_ctx->target_hw_name, hdd_ctx->fw_version_info.siid,
(stt_flag ? info.fw_build_id : " ")); hdd_ctx->fw_version_info.rel_id,
hdd_ctx->fw_version_info.crmid,
hdd_ctx->fw_version_info.sub_id,
hdd_ctx->target_hw_name,
(stt_flag ? info.fw_build_id : " "));
skb_len += strlen(firmware_version) + 1; skb_len += strlen(firmware_version) + 1;
count++; count++;
} }
@@ -7314,6 +7315,7 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
if (count == 0) { if (count == 0) {
hdd_err("unknown attribute in get_wifi_info request"); hdd_err("unknown attribute in get_wifi_info request");
qdf_mem_free(firmware_version);
return -EINVAL; return -EINVAL;
} }
@@ -7322,13 +7324,14 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
if (!reply_skb) { if (!reply_skb) {
hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed"); hdd_err("cfg80211_vendor_cmd_alloc_reply_skb failed");
qdf_mem_free(firmware_version);
return -ENOMEM; return -ENOMEM;
} }
if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) { if (tb_vendor[QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION]) {
if (nla_put_string(reply_skb, if (nla_put_string(reply_skb,
QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION, QCA_WLAN_VENDOR_ATTR_WIFI_INFO_DRIVER_VERSION,
driver_version)) QWLAN_VERSIONSTR))
goto error_nla_fail; goto error_nla_fail;
} }
@@ -7346,10 +7349,12 @@ __wlan_hdd_cfg80211_get_wifi_info(struct wiphy *wiphy,
goto error_nla_fail; goto error_nla_fail;
} }
qdf_mem_free(firmware_version);
return cfg80211_vendor_cmd_reply(reply_skb); return cfg80211_vendor_cmd_reply(reply_skb);
error_nla_fail: error_nla_fail:
hdd_err("nla put fail"); hdd_err("nla put fail");
qdf_mem_free(firmware_version);
kfree_skb(reply_skb); kfree_skb(reply_skb);
return -EINVAL; return -EINVAL;
} }