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

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

Merge "msm: ipc: Update the check for minimum packet size"

parents 689524d6 5da52c67
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);