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

Commit c9709796 authored by Maulik Shah's avatar Maulik Shah
Browse files

drivers: mailbox: rpmh: Correct matching of tcs command sequence



Fix sanity check to match new commands with existing sequence.
Also add check for selected slot to be less than maximum available
slots.

Change-Id: Ib3fc3d87d53d3ac47e53119b0cd4b998d19656ba
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent cd4936b2
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -694,10 +694,11 @@ static int find_match(struct tcs_mbox *tcs, struct tcs_cmd *cmd, int len)
		}
		/* sanity check to ensure the seq is same */
		for (j = 1; j < len; j++) {
			WARN((tcs->cmd_addr[i + j] != cmd[j].addr),
				"Message does not match previous sequence.\n");
			if (tcs->cmd_addr[i + j] != cmd[j].addr) {
				pr_debug("Message does not match previous sequence.\n");
				return -EINVAL;
			}
		}
		found = true;
		break;
	}
@@ -724,12 +725,12 @@ static int find_slots(struct tcs_mbox *tcs, struct tcs_mbox_msg *msg)
	do {
		slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS,
						n, msg->num_payload, 0);
		if (slot == MAX_TCS_SLOTS)
		if (slot >= MAX_TCS_SLOTS)
			break;
		n += tcs->ncpt;
	} while (slot + msg->num_payload - 1 >= n);

	return (slot != MAX_TCS_SLOTS) ? slot : -ENOMEM;
	return (slot < MAX_TCS_SLOTS) ? slot : -ENOMEM;
}

static int tcs_mbox_write(struct mbox_chan *chan, struct tcs_mbox_msg *msg,