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

Commit 0c354b99 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: f_fs: Fix epfile crash during composition switch"

parents ad835c29 7667611e
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -1072,20 +1072,31 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
			 * status. usb_ep_dequeue API should guarantee no race
			 * condition with req->complete callback.
			 */
			spin_lock_irq(&epfile->ffs->eps_lock);
			interrupted = true;
			if (ep->ep) {
				usb_ep_dequeue(ep->ep, req);
				interrupted = ep->status < 0;
			}
			spin_unlock_irq(&epfile->ffs->eps_lock);
		}

		ffs_log("%s:ep status %d for req %pK", epfile->name, ep->status,
				req);

		if (interrupted)
		if (interrupted) {
			ret = -EINTR;
		else if (io_data->read && ep->status > 0)
			goto error_mutex;
		}

		ret = -ENODEV;
		spin_lock_irq(&epfile->ffs->eps_lock);
		if (ep->ep)
			ret = ep->status;
		spin_unlock_irq(&epfile->ffs->eps_lock);
		if (io_data->read && ret > 0)
			ret = __ffs_epfile_read_data(epfile, data, ep->status,
						     &io_data->data);
		else
			ret = ep->status;
		goto error_mutex;
	} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) {
		ret = -ENOMEM;