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

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

Merge "USB: gadget: mass_storage: Fix Null pointer access during disconnect" into msm-4.9

parents 8821ed75 3bfb7867
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -450,13 +450,23 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
	struct fsg_buffhd	*bh = req->context;

	if (req->status || req->actual != req->length)
		DBG(common, "%s --> %d, %u/%u\n", __func__,
		pr_debug("%s --> %d, %u/%u\n", __func__,
		    req->status, req->actual, req->length);
	if (req->status == -ECONNRESET)		/* Request was cancelled */
		usb_ep_fifo_flush(ep);

	/* Hold the lock while we update the request and buffer states */
	smp_wmb();
	/*
	 * Disconnect and completion might race each other and driver data
	 * is set to NULL during ep disable. So, add a check if that is case.
	 */
	if (!common) {
		bh->inreq_busy = 0;
		bh->state = BUF_STATE_EMPTY;
		return;
	}

	spin_lock(&common->lock);
	bh->inreq_busy = 0;
	bh->state = BUF_STATE_EMPTY;