提交 f07af4b6 编写于 作者: D Dan Carpenter 提交者: Greg Kroah-Hartman

USB: wusbcore/wa-xfer: error handling fixes in setup_segs()

1) It didn't free xfer->seg[0] so there was a leak.
2) xfer->seg[cnt] can be NULL.
3) Use usb_free_urb() for ->dto_urb instead of kfree().
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 4d2079c1
......@@ -695,9 +695,9 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size)
cnt--;
error_seg_kzalloc:
/* use the fact that cnt is left at were it failed */
for (; cnt > 0; cnt--) {
if (xfer->is_inbound == 0)
kfree(xfer->seg[cnt]->dto_urb);
for (; cnt >= 0; cnt--) {
if (xfer->seg[cnt] && xfer->is_inbound == 0)
usb_free_urb(xfer->seg[cnt]->dto_urb);
kfree(xfer->seg[cnt]);
}
error_segs_kzalloc:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册