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

Commit f243ed5b authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa
Browse files

USB: gadget: u_bam: Check for port_usb for NULL before ep_unconfig



In gbam2bam_connect_work(), tether_bridge_init() fails, error handling
is being done. As part of error handling, driver is calling
msm_ep_unconfig() for USB endpoints configured. But there is a chance
that disconnect happens during this time and port_usb becomes NULL.
Hence add a check for port_usb under spinlock and if it is not NULL,
don't call msm_ep_unconfig() as disconnect handling already takes care
of it.
Also check whether endless request is NULL or not before queueing it to
USB controller.

Change-Id: Ib7a563c79b1d08581fac9143cb41650ed6c24afd
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent 80f8814a
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -883,7 +883,7 @@ static void gbam_start_endless_rx(struct gbam_port *port)
	unsigned long flags;

	spin_lock_irqsave(&port->port_lock_ul, flags);
	if (!port->port_usb) {
	if (!port->port_usb || !d->rx_req) {
		spin_unlock_irqrestore(&port->port_lock_ul, flags);
		pr_err("%s: port->port_usb is NULL", __func__);
		return;
@@ -905,7 +905,7 @@ static void gbam_start_endless_tx(struct gbam_port *port)
	unsigned long flags;

	spin_lock_irqsave(&port->port_lock_dl, flags);
	if (!port->port_usb) {
	if (!port->port_usb || !d->tx_req) {
		spin_unlock_irqrestore(&port->port_lock_dl, flags);
		pr_err("%s: port->port_usb is NULL", __func__);
		return;
@@ -1512,9 +1512,14 @@ static void gbam2bam_connect_work(struct work_struct *w)

ep_unconfig:
	if (gadget_is_dwc3(gadget)) {
		spin_lock_irqsave(&port->port_lock, flags);
		/* check if USB cable is disconnected or not */
		if (port->port_usb) {
			msm_ep_unconfig(port->port_usb->in);
			msm_ep_unconfig(port->port_usb->out);
		}
		spin_unlock_irqrestore(&port->port_lock, flags);
	}
free_fifos:
	usb_bam_free_fifos(d->usb_bam_type, d->src_connection_idx);
	usb_bam_free_fifos(d->usb_bam_type, d->dst_connection_idx);