qcacld-3.0: Statically allocate wlan logging buffer

To aid in debugging memory leaks, and improve the robustness of log
recovery from crash dumps, statically allocate pglog_msg in the global
scope. This allows logs to be inspected even in cases where a crash
came late in the unload process. It also improves log recovery
robustness by removing the possibility of using a NULL pointer offset
under certain memory corruptions scenarios.

Change-Id: I7301254d3d3ff811b322e435962e78f997937c2b
CRs-Fixed: 2074611
This commit is contained in:
Dustin Brown
2017-07-10 13:02:47 -07:00
committed by snandini
parent 05bdeeac75
commit 7b3dea22f9
3 changed files with 4 additions and 75 deletions

View File

@@ -7899,12 +7899,6 @@ enum hdd_link_speed_rpt_type {
#define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_ENABLE (1) #define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_ENABLE (1)
#define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DISABLE (0) #define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DISABLE (0)
#define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DEFAULT (1) #define CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DEFAULT (1)
/* Number of buffers to be used for WLAN logging */
#define CFG_WLAN_LOGGING_NUM_BUF_NAME "wlanLoggingNumBuf"
#define CFG_WLAN_LOGGING_NUM_BUF_MIN (4)
#define CFG_WLAN_LOGGING_NUM_BUF_MAX (512)
#define CFG_WLAN_LOGGING_NUM_BUF_DEFAULT (256)
#endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */ #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */
/* /*
@@ -12111,9 +12105,8 @@ struct hdd_config {
uint32_t IpaUcTxPartitionBase; uint32_t IpaUcTxPartitionBase;
#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
/* WLAN Logging */ /* WLAN Logging */
uint32_t wlanLoggingEnable; bool wlanLoggingEnable;
uint32_t wlanLoggingToConsole; bool wlanLoggingToConsole;
uint32_t wlanLoggingNumBuf;
#endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */ #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */
uint8_t enableSifsBurst; uint8_t enableSifsBurst;

View File

@@ -3300,13 +3300,6 @@ struct reg_table_entry g_registry_table[] = {
CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DEFAULT, CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DEFAULT,
CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DISABLE, CFG_WLAN_LOGGING_CONSOLE_SUPPORT_DISABLE,
CFG_WLAN_LOGGING_CONSOLE_SUPPORT_ENABLE), CFG_WLAN_LOGGING_CONSOLE_SUPPORT_ENABLE),
REG_VARIABLE(CFG_WLAN_LOGGING_NUM_BUF_NAME, WLAN_PARAM_Integer,
struct hdd_config, wlanLoggingNumBuf,
VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
CFG_WLAN_LOGGING_NUM_BUF_DEFAULT,
CFG_WLAN_LOGGING_NUM_BUF_MIN,
CFG_WLAN_LOGGING_NUM_BUF_MAX),
#endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */ #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */
REG_VARIABLE(CFG_ENABLE_SIFS_BURST, WLAN_PARAM_Integer, REG_VARIABLE(CFG_ENABLE_SIFS_BURST, WLAN_PARAM_Integer,

View File

@@ -5554,57 +5554,6 @@ static int hdd_wlan_register_ip6_notifier(hdd_context_t *hdd_ctx)
} }
#endif #endif
#ifdef WLAN_LOGGING_SOCK_SVC_ENABLE
/**
* hdd_logging_sock_activate_svc() - Activate logging
* @hdd_ctx: HDD context
*
* Activates the logging service
*
* Return: Zero in case of success, negative value otherwise
*/
static int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx)
{
int ret;
struct hdd_config *config = hdd_ctx->config;
if (!config->wlanLoggingEnable)
return 0;
ret = wlan_logging_sock_activate_svc(config->wlanLoggingToConsole,
config->wlanLoggingNumBuf);
if (ret)
hdd_err("wlan_logging_sock_activate_svc failed: %d", ret);
return ret;
}
/**
* wlan_hdd_logging_sock_deactivate_svc() - Deactivate logging
* @hdd_ctx: HDD context
*
* Deactivates the logging service
*
* Return: 0 on deactivating the logging service
*/
static int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx)
{
if (hdd_ctx && hdd_ctx->config->wlanLoggingEnable)
return wlan_logging_sock_deactivate_svc();
return 0;
}
#else
static inline int hdd_logging_sock_activate_svc(hdd_context_t *hdd_ctx)
{
return 0;
}
static inline int hdd_logging_sock_deactivate_svc(hdd_context_t *hdd_ctx)
{
return 0;
}
#endif
/** /**
* hdd_register_notifiers - Register netdev notifiers. * hdd_register_notifiers - Register netdev notifiers.
* @hdd_ctx: HDD context * @hdd_ctx: HDD context
@@ -5867,8 +5816,6 @@ static int hdd_context_deinit(hdd_context_t *hdd_ctx)
static void hdd_context_destroy(hdd_context_t *hdd_ctx) static void hdd_context_destroy(hdd_context_t *hdd_ctx)
{ {
hdd_logging_sock_deactivate_svc(hdd_ctx);
wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); wlan_hdd_deinit_tx_rx_histogram(hdd_ctx);
hdd_context_deinit(hdd_ctx); hdd_context_deinit(hdd_ctx);
@@ -7887,9 +7834,8 @@ static hdd_context_t *hdd_context_create(struct device *dev)
if (ret) if (ret)
goto err_deinit_hdd_context; goto err_deinit_hdd_context;
ret = hdd_logging_sock_activate_svc(hdd_ctx); wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole);
if (ret) wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable);
goto err_free_histogram;
skip_multicast_logging: skip_multicast_logging:
hdd_set_trace_level_for_each(hdd_ctx); hdd_set_trace_level_for_each(hdd_ctx);
@@ -7898,9 +7844,6 @@ skip_multicast_logging:
return hdd_ctx; return hdd_ctx;
err_free_histogram:
wlan_hdd_deinit_tx_rx_histogram(hdd_ctx);
err_deinit_hdd_context: err_deinit_hdd_context:
hdd_context_deinit(hdd_ctx); hdd_context_deinit(hdd_ctx);