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

Commit 6dfc954a authored by Mayank Rana's avatar Mayank Rana
Browse files

USB: u_bam: Add check for USB cable connect



It is observed that in case of running compliance suspend/resume
test case with USB 3.0, device is crashing due to trying to use
USB port structure from gbam2bam_data_connect_work() context
which is already freed. Hence add check for port availability
and port->port_usb before trying to access ep IN and ep OUT data
structure in gbam2bam_data_connect_work() to resolve this issue.

CRs-Fixed: 645110
Change-Id: I491dcf07a9c98f63f156a0cc397d3b698d89b6d8
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent a771904b
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -1279,8 +1279,24 @@ static void gbam2bam_connect_work(struct work_struct *w)
				return;
			}

			if (!port) {
				pr_err("%s: UL: Port is NULL.", __func__);
				return;
			}

			spin_lock_irqsave(&port->port_lock_ul, flags);
			/* check if USB cable is disconnected or not */
			if (!port->port_usb) {
				pr_debug("%s: UL: cable is disconnected.\n",
								 __func__);
				spin_unlock_irqrestore(&port->port_lock_ul,
								flags);
				return;
			}

			configure_data_fifo(d->src_bam_idx, port->port_usb->out,
						d->src_pipe_type);
			spin_unlock_irqrestore(&port->port_lock_ul, flags);
		}

		/* Remove support for UL using system-to-IPA towards DL */
@@ -1312,8 +1328,24 @@ static void gbam2bam_connect_work(struct work_struct *w)
				return;
			}

			if (!port) {
				pr_err("%s: DL: Port is NULL.", __func__);
				return;
			}

			spin_lock_irqsave(&port->port_lock_dl, flags);
			/* check if USB cable is disconnected or not */
			if (!port->port_usb) {
				pr_debug("%s: DL: cable is disconnected.\n",
								__func__);
				spin_unlock_irqrestore(&port->port_lock_dl,
								flags);
				return;
			}

			configure_data_fifo(d->dst_bam_idx, port->port_usb->in,
						d->dst_pipe_type);
			spin_unlock_irqrestore(&port->port_lock_dl, flags);
		}

		gqti_ctrl_update_ipa_pipes(port->port_usb, port->port_num,