diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-02-17 19:30:40 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-02-17 15:16:42 -0800 |
commit | 478ce7203c2cf3f241f11587717336a60d391269 (patch) | |
tree | 65674bcd0c083ff552aadc19580dd6c019580bf0 /drivers/staging/greybus/es2.c | |
parent | b59281ac077414d879e66798f8e44eb976967814 (diff) | |
download | op-kernel-dev-478ce7203c2cf3f241f11587717336a60d391269.zip op-kernel-dev-478ce7203c2cf3f241f11587717336a60d391269.tar.gz |
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: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/es2.c')
-rw-r--r-- | drivers/staging/greybus/es2.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index e39bd58..5ade51e 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -861,7 +861,7 @@ static int apb_get_cport_count(struct usb_device *udev) int retval; __le16 *cport_count; - cport_count = kmalloc(sizeof(*cport_count), GFP_KERNEL); + cport_count = kzalloc(sizeof(*cport_count), GFP_KERNEL); if (!cport_count) return -ENOMEM; @@ -870,9 +870,13 @@ static int apb_get_cport_count(struct usb_device *udev) USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 0, 0, cport_count, sizeof(*cport_count), ES2_TIMEOUT); - if (retval < 0) { + if (retval != sizeof(*cport_count)) { dev_err(&udev->dev, "Cannot retrieve CPort count: %d\n", retval); + + if (retval >= 0) + retval = -EIO; + goto out; } |