dm: fix memory free issue for xhci
remove uninitialized variable "dir", then make sure "xfer->data","xfer->data[i].hcb","xfer->reqs" free correctly. Tracked-On: #4154 Signed-off-by: Junhao Gao <junhao.gao@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
422330d4ab
commit
058b03c3a7
|
@ -1555,7 +1555,7 @@ pci_xhci_alloc_usb_xfer(struct pci_xhci_dev_emu *dev, int epid)
|
||||||
struct usb_xfer *xfer;
|
struct usb_xfer *xfer;
|
||||||
struct xhci_dev_ctx *dev_ctx;
|
struct xhci_dev_ctx *dev_ctx;
|
||||||
struct xhci_endp_ctx *ep_ctx;
|
struct xhci_endp_ctx *ep_ctx;
|
||||||
int dir, max_blk_cnt, i = 0;
|
int max_blk_cnt, i = 0;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
|
@ -1585,8 +1585,8 @@ pci_xhci_alloc_usb_xfer(struct pci_xhci_dev_emu *dev, int epid)
|
||||||
max_blk_cnt = 2048;
|
max_blk_cnt = 2048;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UPRINTF(LFTL, "err: unexpected epid %d type %d dir %d\r\n",
|
UPRINTF(LFTL, "err: unexpected epid %d type %d\r\n",
|
||||||
epid, type, dir);
|
epid, type);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,8 +1608,8 @@ pci_xhci_alloc_usb_xfer(struct pci_xhci_dev_emu *dev, int epid)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
UPRINTF(LINF, "allocate %d blocks for epid %d type %d dir %d\r\n",
|
UPRINTF(LINF, "allocate %d blocks for epid %d type %d\r\n",
|
||||||
max_blk_cnt, epid, type, dir);
|
max_blk_cnt, epid, type);
|
||||||
|
|
||||||
xfer->max_blk_cnt = max_blk_cnt;
|
xfer->max_blk_cnt = max_blk_cnt;
|
||||||
xfer->dev = (void *)dev;
|
xfer->dev = (void *)dev;
|
||||||
|
@ -1617,11 +1617,14 @@ pci_xhci_alloc_usb_xfer(struct pci_xhci_dev_emu *dev, int epid)
|
||||||
return xfer;
|
return xfer;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
for (; i >= 0; i--)
|
if (xfer->data) {
|
||||||
free(xfer->data[i].hcb);
|
for (; i >= 0; i--)
|
||||||
|
if (xfer->data[i].hcb)
|
||||||
free(xfer->data);
|
free(xfer->data[i].hcb);
|
||||||
free(xfer->reqs);
|
free(xfer->data);
|
||||||
|
}
|
||||||
|
if (xfer->reqs)
|
||||||
|
free(xfer->reqs);
|
||||||
free(xfer);
|
free(xfer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue