From be0a4b692bfdea083f7ae38cb31ff5410759bf83 Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Mon, 2 Sep 2019 11:52:26 +0800 Subject: [PATCH] DM USB: fix enumeration related issues The patch fixes enumeration related issues introduced by commit 'fc3d19'. Tracked-On: #3612 Signed-off-by: Xiaoguang Wu Acked-by: Yu Wang --- devicemodel/hw/platform/usb_pmapper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/devicemodel/hw/platform/usb_pmapper.c b/devicemodel/hw/platform/usb_pmapper.c index fa1946bdc..f56b95d34 100644 --- a/devicemodel/hw/platform/usb_pmapper.c +++ b/devicemodel/hw/platform/usb_pmapper.c @@ -962,11 +962,6 @@ usb_dev_request(void *pdata, struct usb_data_xfer *xfer) blk = usb_dev_prepare_ctrl_xfer(xfer); data = blk ? blk->buf : NULL; - if (data == NULL) { - xfer->status = USB_ERR_IOERROR; - UPRINTF(LFTL, "%s unexpected NULL data\r\n", __func__); - goto out; - } UPRINTF(LDBG, "%d-%s: urb: type 0x%x req 0x%x val 0x%x idx %d len %d " "data %d\r\n", udev->info.path.bus, @@ -1016,6 +1011,13 @@ usb_dev_request(void *pdata, struct usb_data_xfer *xfer) } + /* (data == NULL && len == 0) is okey to libusb_control_transfer */ + if (data == NULL && len) { + xfer->status = USB_ERR_IOERROR; + UPRINTF(LFTL, "%s unexpected NULL data\r\n", __func__); + goto out; + } + /* send it to physical device */ /* FIXME: In the process of implementation of USB isochronouse transfer, * the timeout time is not enough for Plantronics headset. So this @@ -1029,7 +1031,7 @@ usb_dev_request(void *pdata, struct usb_data_xfer *xfer) * supported and the following code is used as a workaround now. * UAS will be implemented in future. */ - if (need_chk_uas) + if (need_chk_uas && data) clear_uas_desc(udev, data, rc); if (rc >= 0 && blk) {