Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5d08b6a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "wcnss: fix the race condition issue during cal data extraction"

parents 92b06c47 098498be
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -2109,21 +2109,23 @@ void extract_cal_data(int len)
		return;
	}

	mutex_lock(&penv->dev_lock);
	rc = smd_read(penv->smd_ch, (unsigned char *)&calhdr,
			sizeof(struct cal_data_params));
	if (rc < sizeof(struct cal_data_params)) {
		pr_err("wcnss: incomplete cal header read from smd\n");
		mutex_unlock(&penv->dev_lock);
		return;
	}

	if (penv->fw_cal_exp_frag != calhdr.frag_number) {
		pr_err("wcnss: Invalid frgament");
		goto exit;
		goto unlock_exit;
	}

	if (calhdr.frag_size > WCNSS_MAX_FRAME_SIZE) {
		pr_err("wcnss: Invalid fragment size");
		goto exit;
		goto unlock_exit;
	}

	if (penv->fw_cal_available) {
@@ -2132,8 +2134,9 @@ void extract_cal_data(int len)
		penv->fw_cal_exp_frag++;
		if (calhdr.msg_flags & LAST_FRAGMENT) {
			penv->fw_cal_exp_frag = 0;
			goto exit;
			goto unlock_exit;
		}
		mutex_unlock(&penv->dev_lock);
		return;
	}

@@ -2141,7 +2144,7 @@ void extract_cal_data(int len)
		if (calhdr.total_size > MAX_CALIBRATED_DATA_SIZE) {
			pr_err("wcnss: Invalid cal data size %d",
				calhdr.total_size);
			goto exit;
			goto unlock_exit;
		}
		kfree(penv->fw_cal_data);
		penv->fw_cal_rcvd = 0;
@@ -2149,11 +2152,10 @@ void extract_cal_data(int len)
				GFP_KERNEL);
		if (penv->fw_cal_data == NULL) {
			smd_read(penv->smd_ch, NULL, calhdr.frag_size);
			goto exit;
			goto unlock_exit;
		}
	}

	mutex_lock(&penv->dev_lock);
	if (penv->fw_cal_rcvd + calhdr.frag_size >
			MAX_CALIBRATED_DATA_SIZE) {
		pr_err("calibrated data size is more than expected %d",
@@ -2188,8 +2190,6 @@ void extract_cal_data(int len)

unlock_exit:
	mutex_unlock(&penv->dev_lock);

exit:
	wcnss_send_cal_rsp(fw_status);
	return;
}