From 5ea0f03d0663edbbf55389eaed9126526d201e6b Mon Sep 17 00:00:00 2001 From: Ankita Bajaj Date: Thu, 2 May 2019 19:29:09 +0530 Subject: [PATCH] qcacld-3.0: Return proper error on request id mapping failure When sending keepalive packets if there is failure in mapping request id to pattern id in function - hdd_map_req_id_to_pattern_id(), error code EINVAL is returned. This error code is misleading and not sufficient to inform the userspace that all available buffers are utilized and it should stop sending keepalive packets. Return proper error code if all available buffers are utilized and no buffers are available to address any new request to send keepalive packets. Change-Id: Ie54299a0a7ff43a7044316d641d19ce12ac047c8 CRs-Fixed: 2445981 --- core/hdd/src/wlan_hdd_cfg80211.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 050f482c62b9..be5d984f4113 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -7704,7 +7704,7 @@ static int hdd_map_req_id_to_pattern_id(struct hdd_context *hdd_ctx, } } mutex_unlock(&hdd_ctx->op_ctx.op_lock); - return -EINVAL; + return -ENOBUFS; } /** @@ -7774,7 +7774,8 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, { struct sSirAddPeriodicTxPtrn *add_req; QDF_STATUS status; - uint32_t request_id, ret, len; + uint32_t request_id, len; + int32_t ret; uint8_t pattern_id = 0; struct qdf_mac_addr dst_addr; uint16_t eth_type = htons(ETH_P_IP); @@ -7792,18 +7793,21 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, /* Parse and fetch request Id */ if (!tb[PARAM_REQUEST_ID]) { hdd_err("attr request id failed"); + ret = -EINVAL; goto fail; } request_id = nla_get_u32(tb[PARAM_REQUEST_ID]); if (request_id == MAX_REQUEST_ID) { hdd_err("request_id cannot be MAX"); + ret = -EINVAL; goto fail; } hdd_debug("Request Id: %u", request_id); if (!tb[PARAM_PERIOD]) { hdd_err("attr period failed"); + ret = -EINVAL; goto fail; } @@ -7811,11 +7815,13 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, hdd_debug("Period: %u ms", add_req->usPtrnIntervalMs); if (add_req->usPtrnIntervalMs == 0) { hdd_err("Invalid interval zero, return failure"); + ret = -EINVAL; goto fail; } if (!tb[PARAM_SRC_MAC_ADDR]) { hdd_err("attr source mac address failed"); + ret = -EINVAL; goto fail; } nla_memcpy(add_req->mac_address.bytes, tb[PARAM_SRC_MAC_ADDR], @@ -7826,11 +7832,13 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, if (!qdf_is_macaddr_equal(&add_req->mac_address, &adapter->mac_addr)) { hdd_err("input src mac address and connected ap bssid are different"); + ret = -EINVAL; goto fail; } if (!tb[PARAM_DST_MAC_ADDR]) { hdd_err("attr dst mac address failed"); + ret = -EINVAL; goto fail; } nla_memcpy(dst_addr.bytes, tb[PARAM_DST_MAC_ADDR], QDF_MAC_ADDR_SIZE); @@ -7839,6 +7847,7 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, if (!tb[PARAM_IP_PACKET]) { hdd_err("attr ip packet failed"); + ret = -EINVAL; goto fail; } add_req->ucPtrnSize = nla_len(tb[PARAM_IP_PACKET]); @@ -7849,6 +7858,7 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, ETH_HLEN)) { hdd_err("Invalid IP packet len: %d", add_req->ucPtrnSize); + ret = -EINVAL; goto fail; } @@ -7891,16 +7901,15 @@ wlan_hdd_add_tx_ptrn(struct hdd_adapter *adapter, struct hdd_context *hdd_ctx, status = sme_add_periodic_tx_ptrn(mac_handle, add_req); if (!QDF_IS_STATUS_SUCCESS(status)) { hdd_err("sme_add_periodic_tx_ptrn failed (err=%d)", status); + ret = qdf_status_to_os_return(status); goto fail; } hdd_exit(); - qdf_mem_free(add_req); - return 0; fail: qdf_mem_free(add_req); - return -EINVAL; + return ret; } /**