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

Commit 5da52c67 authored by Karthikeyan Ramasubramanian's avatar Karthikeyan Ramasubramanian
Browse files

msm: ipc: Update the check for minimum packet size



IPC Router checks for the minimum packet size of the incoming message to
be at least 32 bytes. With IPC Router version 2 header, this check is
invalid for some packets.

Update the check for the minimum incoming packet size based on the
transport on which the packet is received.

Change-Id: Iacebfe876db2e5c3513d18fcfae425ea9bd6a7cd
Signed-off-by: default avatarKarthikeyan Ramasubramanian <kramasub@codeaurora.org>
parent 3a5255f7
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -616,6 +616,27 @@ static int calc_tx_header_size(struct rr_packet *pkt,
	return hdr_size;
}

/**
 * calc_rx_header_size() - Calculate the RX header size
 * @xprt_info: XPRT info of the received message.
 *
 * @return: valid header size on success, INT_MAX on failure.
 */
static int calc_rx_header_size(struct msm_ipc_router_xprt_info *xprt_info)
{
	int xprt_version = 0;
	int hdr_size = INT_MAX;

	if (xprt_info)
		xprt_version = xprt_info->xprt->get_version(xprt_info->xprt);

	if (xprt_version == IPC_ROUTER_V1)
		hdr_size = sizeof(struct rr_header_v1);
	else if (xprt_version == IPC_ROUTER_V2)
		hdr_size = sizeof(struct rr_header_v2);
	return hdr_size;
}

/**
 * prepend_header_v1() - Prepend IPC Router header of version 1
 * @pkt: Packet structure which contains the header info to be prepended.
@@ -2080,7 +2101,7 @@ static void do_read_data(struct work_struct *work)
			     read_data);

	while ((pkt = rr_read(xprt_info)) != NULL) {
		if (pkt->length < IPC_ROUTER_HDR_SIZE ||
		if (pkt->length < calc_rx_header_size(xprt_info) ||
		    pkt->length > MAX_IPC_PKT_SIZE) {
			pr_err("%s: Invalid pkt length %d\n",
				__func__, pkt->length);