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

Commit e7f08c73 authored by Anji Jonnala's avatar Anji Jonnala Committed by Maulik Shah
Browse files

msm: rpm-smd: Add a check to validate the rpm message length



Print the msg_id associated with error communication and
also leave a print message for fatal errors in rpm_smd_work.

Change-Id: If0f3b1b5b08fb80a9036219bef6c5577f7fadbe8
Signed-off-by: default avatarAchyuth Sai Vadrav <avadra@codeaurora.org>
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent f0be97f2
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -378,6 +378,7 @@ static inline int msm_rpm_get_error_from_ack(uint8_t *buf)
	uint8_t *tmp;
	uint32_t req_len = ((struct msm_rpm_ack_msg *)buf)->req_len;

	struct msm_rpm_ack_msg *tmp_buf = (struct msm_rpm_ack_msg *)buf;
	int rc = -ENODEV;

	req_len -= sizeof(struct msm_rpm_ack_msg);
@@ -385,9 +386,15 @@ static inline int msm_rpm_get_error_from_ack(uint8_t *buf)
	if (!req_len)
		return 0;

	pr_err("%s:rpm returned error or nack req_len: %d id_ack: %d\n",
				__func__, tmp_buf->req_len, tmp_buf->id_ack);

	tmp = buf + sizeof(struct msm_rpm_ack_msg);

	BUG_ON(memcmp(tmp, ERR, sizeof(uint32_t)));
	if (memcmp(tmp, ERR, sizeof(uint32_t))) {
		pr_err("%s rpm returned error\n", __func__);
		BUG_ON(1);
	}

	tmp += 2 * sizeof(uint32_t);

@@ -925,7 +932,10 @@ static int msm_rpm_read_smd_data(char *buf)
	if (!pkt_sz)
		return -EAGAIN;

	BUG_ON(pkt_sz > MAX_ERR_BUFFER_SIZE);
	if (pkt_sz > MAX_ERR_BUFFER_SIZE) {
		pr_err("rpm_smd pkt_sz is greater than max size\n");
		goto error;
	}

	if (pkt_sz != smd_read_avail(msm_rpm_data.ch_info))
		return -EAGAIN;
@@ -939,7 +949,13 @@ static int msm_rpm_read_smd_data(char *buf)

	} while (pkt_sz > 0);

	BUG_ON(pkt_sz < 0);
	if (pkt_sz < 0) {
		pr_err("rpm_smd pkt_sz is less than zero\n");
		goto error;
	}
	return 0;
error:
	BUG_ON(1);

	return 0;
}