[PATCH 4.9 34/65] usbip: Fix vhci_urb_enqueue() URB null transfer buffer error path

From: Greg Kroah-Hartman
Date: Mon Nov 11 2019 - 13:33:26 EST


From: Shuah Khan <shuah@xxxxxxxxxx>

commit 2c904963b1dd2acd4bc785b6c72e10a6283c2081 upstream.

Fix vhci_urb_enqueue() to print debug msg and return error instead of
failing with BUG_ON.

Signed-off-by: Shuah Khan <shuah@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/usb/usbip/vhci_hcd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -512,8 +512,10 @@ static int vhci_urb_enqueue(struct usb_h
}
vdev = &vhci->vdev[portnum-1];

- /* patch to usb_sg_init() is in 2.5.60 */
- BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
+ if (!urb->transfer_buffer && urb->transfer_buffer_length) {
+ dev_dbg(dev, "Null URB transfer buffer\n");
+ return -EINVAL;
+ }

spin_lock_irqsave(&vhci->lock, flags);