ACRN:DM:xHCI Fix the unsigned integer conversion bug

When libusb_control_transfer function return a negative number, because
 the function clear_uas_desc's argument is unsigned int this will cause
 unsigned integer conversion.

Tracked-On: #5463
Signed-off-by: Liu Long <long.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Liu Long 2020-10-30 16:44:59 +08:00 committed by wenlingz
parent 49b6e12895
commit 0c6682e845

View File

@ -889,7 +889,7 @@ done:
}
static void
clear_uas_desc(struct usb_dev *udev, uint8_t *data, uint32_t len)
clear_uas_desc(struct usb_dev *udev, uint8_t *data, int len)
{
struct usb_devpath *path;
int32_t i;
@ -1013,6 +1013,10 @@ usb_dev_request(void *pdata, struct usb_xfer *xfer)
rc = libusb_control_transfer(udev->handle, request_type, request,
value, index, data, len, 300);
if (rc < 0) {
xfer->status = usb_dev_err_convert(rc);
goto out;
}
/* TODO: Currently, the USB Attached SCSI (UAS) protocol is not
* supported and the following code is used as a workaround now.
* UAS will be implemented in future.
@ -1020,15 +1024,14 @@ usb_dev_request(void *pdata, struct usb_xfer *xfer)
if (need_chk_uas && data)
clear_uas_desc(udev, data, rc);
if (rc >= 0 && blk) {
if (blk) {
blk->blen = len - rc;
blk->bdone += rc;
xfer->status = blk->blen > 0 ? USB_ERR_SHORT_XFER :
USB_ERR_NORMAL_COMPLETION;
} else if (rc >= 0)
} else
xfer->status = USB_ERR_NORMAL_COMPLETION;
else
xfer->status = usb_dev_err_convert(rc);
UPRINTF(LDBG, "%d-%s: usb rc %d, blk %p, blen %u bdon %u\n",
udev->info.path.bus, usb_dev_path(&udev->info.path),