Commit 478ce720 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: es2: fix cport-count error handling

Make sure to check for short transfers when retrieving the bridge cport
count.

Also clear the request buffer when allocating it.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent b59281ac
...@@ -861,7 +861,7 @@ static int apb_get_cport_count(struct usb_device *udev) ...@@ -861,7 +861,7 @@ static int apb_get_cport_count(struct usb_device *udev)
int retval; int retval;
__le16 *cport_count; __le16 *cport_count;
cport_count = kmalloc(sizeof(*cport_count), GFP_KERNEL); cport_count = kzalloc(sizeof(*cport_count), GFP_KERNEL);
if (!cport_count) if (!cport_count)
return -ENOMEM; return -ENOMEM;
...@@ -870,9 +870,13 @@ static int apb_get_cport_count(struct usb_device *udev) ...@@ -870,9 +870,13 @@ static int apb_get_cport_count(struct usb_device *udev)
USB_DIR_IN | USB_TYPE_VENDOR | USB_DIR_IN | USB_TYPE_VENDOR |
USB_RECIP_INTERFACE, 0, 0, cport_count, USB_RECIP_INTERFACE, 0, 0, cport_count,
sizeof(*cport_count), ES2_TIMEOUT); sizeof(*cport_count), ES2_TIMEOUT);
if (retval < 0) { if (retval != sizeof(*cport_count)) {
dev_err(&udev->dev, "Cannot retrieve CPort count: %d\n", dev_err(&udev->dev, "Cannot retrieve CPort count: %d\n",
retval); retval);
if (retval >= 0)
retval = -EIO;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment