Sfoglia il codice sorgente

qcacmn: Return from function if pointers are NULL

In some MLO functions, there are NULL pointer checks, but the logic
continues even if it is NULL. Return from the function in this case so
there is no potential NULL pointer dereference. This also addresses
a static analysis issue.

Change-Id: I22c4a47d724d8576a2ce78059dec219cbc3de91e
CRs-fixed: 3127461
Lincoln Tran 3 anni fa
parent
commit
94df448341
1 ha cambiato i file con 18 aggiunte e 15 eliminazioni
  1. 18 15
      umac/mlo_mgr/src/wlan_mlo_mgr_sta.c

+ 18 - 15
umac/mlo_mgr/src/wlan_mlo_mgr_sta.c

@@ -716,8 +716,12 @@ void mlo_sta_link_connect_notify(struct wlan_objmgr_vdev *vdev,
 	struct wlan_mlo_dev_context *mlo_dev_ctx = vdev->mlo_dev_ctx;
 	struct wlan_mlo_sta *sta_ctx = NULL;
 
-	if (mlo_dev_ctx)
+	if (mlo_dev_ctx) {
 		sta_ctx = mlo_dev_ctx->sta_ctx;
+	} else {
+		mlo_debug_rl("mlo_dev_ctx is NULL");
+		return;
+	}
 
 	if (wlan_cm_is_vdev_disconnected(vdev)) {
 		if (sta_ctx) {
@@ -744,25 +748,22 @@ void mlo_sta_link_connect_notify(struct wlan_objmgr_vdev *vdev,
 			return;
 		}
 
-		if (!wlan_vdev_mlme_is_mlo_link_vdev(vdev)) {
-			if (mlo_dev_ctx->sta_ctx->assoc_rsp.ptr) {
-				qdf_mem_free(
-					mlo_dev_ctx->sta_ctx->assoc_rsp.ptr);
-				mlo_dev_ctx->sta_ctx->assoc_rsp.ptr = NULL;
+		if (!wlan_vdev_mlme_is_mlo_link_vdev(vdev) && sta_ctx) {
+			if (sta_ctx->assoc_rsp.ptr) {
+				qdf_mem_free(sta_ctx->assoc_rsp.ptr);
+				sta_ctx->assoc_rsp.ptr = NULL;
 			}
-			mlo_dev_ctx->sta_ctx->assoc_rsp.len =
-				rsp->connect_ies.assoc_rsp.len;
-			mlo_dev_ctx->sta_ctx->assoc_rsp.ptr =
+			sta_ctx->assoc_rsp.len = rsp->connect_ies.assoc_rsp.len;
+			sta_ctx->assoc_rsp.ptr =
 				qdf_mem_malloc(rsp->connect_ies.assoc_rsp.len);
-			if (!mlo_dev_ctx->sta_ctx->assoc_rsp.ptr) {
+			if (!sta_ctx->assoc_rsp.ptr) {
 				QDF_ASSERT(0);
 				return;
 			}
 			if (rsp->connect_ies.assoc_rsp.ptr)
-				qdf_mem_copy(
-					mlo_dev_ctx->sta_ctx->assoc_rsp.ptr,
-					rsp->connect_ies.assoc_rsp.ptr,
-					rsp->connect_ies.assoc_rsp.len);
+				qdf_mem_copy(sta_ctx->assoc_rsp.ptr,
+					     rsp->connect_ies.assoc_rsp.ptr,
+					     rsp->connect_ies.assoc_rsp.len);
 			/* Update connected_links_bmap for all vdev taking
 			 * part in association
 			 */
@@ -1162,11 +1163,13 @@ void mlo_get_assoc_rsp(struct wlan_objmgr_vdev *vdev,
 		       struct element_info *assoc_rsp_frame)
 {
 	struct wlan_mlo_dev_context *mlo_dev_ctx = vdev->mlo_dev_ctx;
-	struct wlan_mlo_sta *sta_ctx = mlo_dev_ctx->sta_ctx;
+	struct wlan_mlo_sta *sta_ctx = NULL;
 
 	if (!mlo_dev_ctx || !mlo_dev_ctx->sta_ctx)
 		return;
 
+	sta_ctx = mlo_dev_ctx->sta_ctx;
+
 	if (!sta_ctx->assoc_rsp.len || !sta_ctx->assoc_rsp.ptr) {
 		mlo_err("Assoc Resp info is empty");
 		return;