From b994a75a34119dc61607eeb4e2419e11fa7d62d8 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Dhanotiya Date: Thu, 12 Mar 2020 12:35:16 +0530 Subject: [PATCH] qcacld-3.0: Allocate vdev private data along with vdev Currently vdev private data osif_priv gets allocation separately and requires to be de-alloc separately. This de-alloc needs to be taken care at different places based on the vdev create failure or whenever vdev is freed. As vdev private data is associated to the vdev and needs to be freed if vdev is not there, it is good to allocate this private data along with vdev so that there is no need to maintain allocation and de-allocation of vdev priv data separately. As part of this change alloc the vdev priv data along with the vdev allocation as a single memory and free of the vdev priv data will be taken care as part of vdev free. Change-Id: I8d4b94cae564c7f2498f7b8cc8aa84a2edd6420d CRs-Fixed: 2634998 --- core/hdd/src/wlan_hdd_main.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 6bcd4eb02f7b..5a38f23cc8da 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -4983,22 +4983,6 @@ bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) return 0; } -static struct vdev_osif_priv * -hdd_init_vdev_os_priv(struct hdd_adapter *adapter) -{ - struct vdev_osif_priv *os_priv; - - os_priv = qdf_mem_malloc(sizeof(*os_priv)); - if (!os_priv) - return NULL; - - /* Initialize the vdev OS private structure*/ - os_priv->wdev = adapter->dev->ieee80211_ptr; - os_priv->legacy_osif_priv = adapter; - - return os_priv; -} - int hdd_vdev_create(struct hdd_adapter *adapter) { QDF_STATUS status; @@ -5021,24 +5005,23 @@ int hdd_vdev_create(struct hdd_adapter *adapter) return errno; } - osif_priv = hdd_init_vdev_os_priv(adapter); - if (!osif_priv) { - hdd_err("Failed to allocate osif_priv"); - return -ENOMEM; - } - vdev_params.opmode = adapter->device_mode; - vdev_params.osifp = osif_priv; qdf_mem_copy(vdev_params.macaddr, adapter->mac_addr.bytes, QDF_NET_MAC_ADDR_MAX_LEN); + vdev_params.size_vdev_priv = sizeof(*osif_priv); vdev = sme_vdev_create(hdd_ctx->mac_handle, &vdev_params); if (!vdev) { hdd_err("failed to create vdev"); return -EINVAL; } + /* Initialize the vdev OS private structure*/ + osif_priv = wlan_vdev_get_ospriv(vdev); + osif_priv->wdev = adapter->dev->ieee80211_ptr; + osif_priv->legacy_osif_priv = adapter; + if (wlan_objmgr_vdev_try_get_ref(vdev, WLAN_HDD_ID_OBJ_MGR) != QDF_STATUS_SUCCESS) { errno = QDF_STATUS_E_INVAL; @@ -9996,7 +9979,7 @@ wlan_hdd_get_adapter_by_vdev_id_from_objmgr(struct hdd_context *hdd_ctx, if (!hdd_ctx) return QDF_STATUS_E_INVAL; - if (!vdev || !vdev->vdev_nif.osdev) { + if (!vdev) { hdd_err("null vdev object"); return QDF_STATUS_E_INVAL; }