소스 검색

qcacmn: Add NULL checks before accessing pldev

Add NULL checks before accessing pldev object in the pktlog module.

Change-Id: I7139480c028a54fab9d73d5b68494cc42ef6d427
CRs-Fixed: 2158642
psimha 7 년 전
부모
커밋
9aec0b53dc
1개의 변경된 파일26개의 추가작업 그리고 9개의 파일을 삭제
  1. 26 9
      utils/pktlog/pktlog_ac.c

+ 26 - 9
utils/pktlog/pktlog_ac.c

@@ -424,13 +424,14 @@ int pktlog_disable(struct hif_opaque_softc *scn)
 	struct cdp_pdev *txrx_pdev = get_txrx_context();
 
 	pl_dev = get_pktlog_handle();
-	pl_info = pl_dev->pl_info;
 
 	if (!pl_dev) {
 		qdf_print("Invalid pl_dev");
 		return -EINVAL;
 	}
 
+	pl_info = pl_dev->pl_info;
+
 	if (!pl_dev->pl_info) {
 		qdf_print("Invalid pl_info");
 		return -EINVAL;
@@ -654,16 +655,18 @@ int pktlog_enable(struct hif_opaque_softc *scn, int32_t log_state,
 	int err;
 
 	pl_dev = get_pktlog_handle();
-	pl_info = pl_dev->pl_info;
 
 	if (!pl_dev) {
 		qdf_print("%s: invalid pl_dev handle", __func__);
 		return -EINVAL;
 	}
 
-	if (!pl_info)
-		return 0;
+	pl_info = pl_dev->pl_info;
 
+	if (!pl_info) {
+		qdf_print("%s: invalid pl_info handle", __func__);
+		return -EINVAL;
+	}
 
 	mutex_lock(&pl_info->pktlog_mutex);
 	err = __pktlog_enable(scn, log_state, ini_triggered,
@@ -682,19 +685,21 @@ static int __pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 	struct cdp_pdev *pdev;
 
 	pl_dev = get_pktlog_handle();
-	pl_info = pl_dev->pl_info;
-	pdev = get_txrx_context();
 
 	if (!pl_dev) {
 		qdf_print("%s: invalid pl_dev handle", __func__);
 		return -EINVAL;
 	}
 
-	if (!pl_dev->pl_info) {
+	pl_info = pl_dev->pl_info;
+
+	if (!pl_info) {
 		qdf_print("%s: invalid pl_dev handle", __func__);
 		return -EINVAL;
 	}
 
+	pdev = get_txrx_context();
+
 	if (!pdev) {
 		qdf_print("%s: invalid pdev handle", __func__);
 		return -EINVAL;
@@ -762,8 +767,19 @@ int pktlog_setsize(struct hif_opaque_softc *scn, int32_t size)
 	int status;
 
 	pl_dev = get_pktlog_handle();
+
+	if (!pl_dev) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return -EINVAL;
+	}
+
 	pl_info = pl_dev->pl_info;
 
+	if (!pl_info) {
+		qdf_print("%s: invalid pl_dev handle", __func__);
+		return -EINVAL;
+	}
+
 	mutex_lock(&pl_info->pktlog_mutex);
 	status = __pktlog_setsize(scn, size);
 	mutex_unlock(&pl_info->pktlog_mutex);
@@ -778,14 +794,15 @@ int pktlog_clearbuff(struct hif_opaque_softc *scn, bool clear_buff)
 	uint8_t save_pktlog_state;
 
 	pl_dev = get_pktlog_handle();
-	pl_info = pl_dev->pl_info;
 
 	if (!pl_dev) {
 		qdf_print("%s: invalid pl_dev handle", __func__);
 		return -EINVAL;
 	}
 
-	if (!pl_dev->pl_info) {
+	pl_info = pl_dev->pl_info;
+
+	if (!pl_info) {
 		qdf_print("%s: invalid pl_dev handle", __func__);
 		return -EINVAL;
 	}