diff --git a/core/wma/inc/wma.h b/core/wma/inc/wma.h index 606c95f645df..872e841dd322 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 6a8acdb88f46..7366752b5425 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -187,6 +187,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