From 328cdc189cbb49e3d1952570f78fa4c41e1267cb Mon Sep 17 00:00:00 2001 From: Srinivas Girigowda Date: Wed, 18 Nov 2020 20:44:35 -0800 Subject: [PATCH] qcacld-3.0: Introduce wma_validate_handle() Introduce wma_validate_handle() with the caller function name embedded in it to validate the WMA handle and log incase of error. Calling functions can avoid logging in case wma_validate_handle() returns -EINVAL. This reduces logging and thereby memory foot print. Change-Id: If38436a590d8b950509bde40468b9ddc3cf33e8d CRs-Fixed: 2833040 --- core/wma/inc/wma.h | 10 ++++++++++ core/wma/src/wma_main.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/core/wma/inc/wma.h b/core/wma/inc/wma.h index 4a63701095..6381cbbf66 100644 --- a/core/wma/inc/wma.h +++ b/core/wma/inc/wma.h @@ -1040,6 +1040,16 @@ typedef struct { bool enable_tx_compl_tsf64; } t_wma_handle, *tp_wma_handle; +/** + * wma_validate_handle() - Validate WMA handle + * @wma_handle: wma handle + * + * Return: errno if WMA handle is NULL; 0 otherwise + */ +#define wma_validate_handle(wma_handle) \ + __wma_validate_handle(wma_handle, __func__) +int __wma_validate_handle(tp_wma_handle wma_handle, const char *func); + /** * wma_vdev_nss_chain_params_send() - send vdev nss chain params to fw. * @vdev_id: vdev_id diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index 1cd92c362b..bd2eb337fe 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -177,6 +177,16 @@ struct wma_ini_config *wma_get_ini_handle(tp_wma_handle wma) return &wma->ini_config; } +int __wma_validate_handle(tp_wma_handle wma_handle, const char *func) +{ + if (!wma_handle) { + wma_err("Invalid WMA handle (via %s)", func); + return -EINVAL; + } + + return 0; +} + #define MAX_SUPPORTED_PEERS_REV1_1 14 #define MAX_SUPPORTED_PEERS_REV1_3 32 #ifdef WLAN_MAX_CLIENTS_ALLOWED