qcacld-3.0: Fix CDS layering violation in hdd_wlan_start_modules()

Currently hdd_wlan_start_modules() gets a pointer to the CDS Global
Context, and then in the failure path it dereferences this pointer to
call hdd_hif_close().  This is a layering violation -- HDD should not
be aware of the contents of the CDS Global Context and should not be
dereferencing the pointer.

Modify the code to use the exported cds_get_context() API to retrieve
this information.

Change-Id: I640bea70b50d5533afa1ee1b2e0cd6b9619a4ac2
CRs-Fixed: 2118692
This commit is contained in:
Jeff Johnson 2017-09-28 14:56:02 -07:00 • committed by snandini
commit 60dc2b18f1

View file

@ -2222,27 +2222,17 @@ static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx)
*
* Return: 0 for success; non-zero for failure
*/
int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter,
int hdd_wlan_start_modules(struct hdd_context *hdd_ctx,
struct hdd_adapter *adapter,
bool reinit)
{
int ret;
qdf_device_t qdf_dev;
QDF_STATUS status;
p_cds_contextType p_cds_context;
bool unint = false;
void *hif_ctx;
ENTER();
p_cds_context = cds_get_global_context();
if (!p_cds_context) {
hdd_err("Global Context is NULL");
QDF_ASSERT(0);
return -EINVAL;
}
hdd_debug("start modules called in state! :%d reinit: %d",
hdd_ctx->driver_status, reinit);
hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit);
qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
if (!qdf_dev) {
@ -2400,7 +2390,8 @@ ol_cds_free:
ol_cds_free();
hif_close:
hdd_hif_close(hdd_ctx, p_cds_context->pHIFContext);
hif_ctx = cds_get_context(QDF_MODULE_ID_HIF);
hdd_hif_close(hdd_ctx, hif_ctx);
power_down:
if (!reinit && !unint)
pld_power_off(qdf_dev->dev);