From fc3d19bee4b2f42af111f5235b9d9ac67347ca6d Mon Sep 17 00:00:00 2001 From: Xiaoguang Wu Date: Thu, 22 Aug 2019 16:34:38 +0800 Subject: [PATCH] DM USB: fix potential crash risk due to null pointer Fix potential risk to crash due to null pointer. Tracked-On: #3612 Signed-off-by: Xiaoguang Wu Acked-by: Yu Wang --- devicemodel/hw/platform/usb_pmapper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devicemodel/hw/platform/usb_pmapper.c b/devicemodel/hw/platform/usb_pmapper.c index 449ddcb30..fa1946bdc 100644 --- a/devicemodel/hw/platform/usb_pmapper.c +++ b/devicemodel/hw/platform/usb_pmapper.c @@ -962,6 +962,11 @@ 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,