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

Commit e6a3fce3 authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa Committed by Gerrit - the friendly Code Review server
Browse files

USB: f_accessory: Fix NULL pointer dereference in acc_read()



If user tries to read /dev/usb_accessory node, it results in calling
acc_read() callback. If accessory interface is not present in current
USB composition, it will lead to crash as dev->ep_out is NULL. Fix
the issue by moving problematic code down after device becomes online.

Change-Id: I6441f6dc3cbe3a84a384fa3e8a6583f65a74659d
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent 56cf6cbf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -580,8 +580,6 @@ static ssize_t acc_read(struct file *fp, char __user *buf,
	if (count > BULK_BUFFER_SIZE)
		count = BULK_BUFFER_SIZE;

	len = ALIGN(count, dev->ep_out->maxpacket);

	/* we will block until we're online */
	pr_debug("acc_read: waiting for online\n");
	ret = wait_event_interruptible(dev->read_wq, dev->online);
@@ -590,6 +588,8 @@ static ssize_t acc_read(struct file *fp, char __user *buf,
		goto done;
	}

	len = ALIGN(count, dev->ep_out->maxpacket);

	if (dev->rx_done) {
		// last req cancelled. try to get it.
		req = dev->rx_req[0];