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

Commit 173db0eb authored by Katish Paran's avatar Katish Paran Committed by Gerrit - the friendly Code Review server
Browse files

diag: Rectify the recovery algorithm in case for raw packet



Currently, while receiving packet in hdlc disabled format, it may
happen that the terminating control character is missing. In that
case the recovery algorithm may hit into infinite loop. This
patch rectifies the error condition.

Change-Id: I50861b94599d50c108cd41c765690b3f6ee0823c
Signed-off-by: default avatarKatish Paran <kparan@codeaurora.org>
parent cc699d74
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1226,19 +1226,21 @@ static void diag_hdlc_start_recovery(unsigned char *buf, int len)
	int i;
	static uint32_t bad_byte_counter;
	unsigned char *start_ptr = NULL;
	struct diag_pkt_frame_t *actual_pkt = NULL;

	hdlc_reset = 1;
	hdlc_reset_timer_start();

	actual_pkt = (struct diag_pkt_frame_t *)buf;
	for (i = 0; i < len; i++) {
		if (buf[i] == CONTROL_CHAR && (i +
				sizeof(struct diag_pkt_frame_t)
				<= (len - 1))) {
			if (buf[i+1] == 1) {
		if (actual_pkt->start == CONTROL_CHAR &&
			actual_pkt->version == 1 &&
			actual_pkt->length < len &&
			(*(uint8_t *)(buf + sizeof(struct diag_pkt_frame_t) +
			actual_pkt->length) == CONTROL_CHAR)) {
				start_ptr = &buf[i];
				break;
		}
		}
		bad_byte_counter++;
		if (bad_byte_counter > (DIAG_MAX_REQ_SIZE +
				sizeof(struct diag_pkt_frame_t) + 1)) {
+4 −0
Original line number Diff line number Diff line
@@ -615,6 +615,10 @@ static void socket_read_work_fn(struct work_struct *work)
	struct diag_socket_info *info = container_of(work,
						     struct diag_socket_info,
						     read_work);

	if (!info)
		return;

	diagfwd_channel_read(info->fwd_ctxt);
}