* [PATCH] usb: call usb_packet_cleanup on usb_packet_map failure
@ 2020-09-01 5:27 Gerd Hoffmann
2020-09-01 9:33 ` Philippe Mathieu-Daudé
2020-09-01 9:51 ` Li Qiang
0 siblings, 2 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2020-09-01 5:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, ppandit
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/usb/hcd-ehci.c | 2 ++
hw/usb/hcd-xhci.c | 1 +
2 files changed, 3 insertions(+)
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 2b995443fbfd..67847a9cf5f1 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -1373,6 +1373,7 @@ static int ehci_execute(EHCIPacket *p, const char *action)
usb_packet_setup(&p->packet, p->pid, ep, 0, p->qtdaddr, spd,
(p->qtd.token & QTD_TOKEN_IOC) != 0);
if (usb_packet_map(&p->packet, &p->sgl)) {
+ usb_packet_cleanup(&p->packet);
qemu_sglist_destroy(&p->sgl);
return -1;
}
@@ -1456,6 +1457,7 @@ static int ehci_process_itd(EHCIState *ehci,
usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false,
(itd->transact[i] & ITD_XACT_IOC) != 0);
if (usb_packet_map(&ehci->ipacket, &ehci->isgl)) {
+ usb_packet_cleanup(&ehci->ipacket);
qemu_sglist_destroy(&ehci->isgl);
return -1;
}
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 46a2186d912a..9b156048920d 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -1616,6 +1616,7 @@ static int xhci_setup_packet(XHCITransfer *xfer)
usb_packet_setup(&xfer->packet, dir, ep, xfer->streamid,
xfer->trbs[0].addr, false, xfer->int_req);
if (usb_packet_map(&xfer->packet, &xfer->sgl)) {
+ usb_packet_cleanup(&xfer->packet);
qemu_sglist_destroy(&xfer->sgl);
return -1;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: call usb_packet_cleanup on usb_packet_map failure
2020-09-01 5:27 [PATCH] usb: call usb_packet_cleanup on usb_packet_map failure Gerd Hoffmann
@ 2020-09-01 9:33 ` Philippe Mathieu-Daudé
2020-09-01 9:51 ` Li Qiang
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-01 9:33 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel; +Cc: ppandit
On 9/1/20 7:27 AM, Gerd Hoffmann wrote:
Reported-by: Prasad J Pandit <pjp@fedoraproject.org>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/usb/hcd-ehci.c | 2 ++
> hw/usb/hcd-xhci.c | 1 +
> 2 files changed, 3 insertions(+)
>
> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> index 2b995443fbfd..67847a9cf5f1 100644
> --- a/hw/usb/hcd-ehci.c
> +++ b/hw/usb/hcd-ehci.c
> @@ -1373,6 +1373,7 @@ static int ehci_execute(EHCIPacket *p, const char *action)
> usb_packet_setup(&p->packet, p->pid, ep, 0, p->qtdaddr, spd,
> (p->qtd.token & QTD_TOKEN_IOC) != 0);
> if (usb_packet_map(&p->packet, &p->sgl)) {
> + usb_packet_cleanup(&p->packet);
> qemu_sglist_destroy(&p->sgl);
> return -1;
> }
> @@ -1456,6 +1457,7 @@ static int ehci_process_itd(EHCIState *ehci,
> usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false,
> (itd->transact[i] & ITD_XACT_IOC) != 0);
> if (usb_packet_map(&ehci->ipacket, &ehci->isgl)) {
> + usb_packet_cleanup(&ehci->ipacket);
> qemu_sglist_destroy(&ehci->isgl);
> return -1;
> }
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index 46a2186d912a..9b156048920d 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -1616,6 +1616,7 @@ static int xhci_setup_packet(XHCITransfer *xfer)
> usb_packet_setup(&xfer->packet, dir, ep, xfer->streamid,
> xfer->trbs[0].addr, false, xfer->int_req);
> if (usb_packet_map(&xfer->packet, &xfer->sgl)) {
> + usb_packet_cleanup(&xfer->packet);
> qemu_sglist_destroy(&xfer->sgl);
> return -1;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: call usb_packet_cleanup on usb_packet_map failure
2020-09-01 5:27 [PATCH] usb: call usb_packet_cleanup on usb_packet_map failure Gerd Hoffmann
2020-09-01 9:33 ` Philippe Mathieu-Daudé
@ 2020-09-01 9:51 ` Li Qiang
1 sibling, 0 replies; 3+ messages in thread
From: Li Qiang @ 2020-09-01 9:51 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: Qemu Developers, P J P
Gerd Hoffmann <kraxel@redhat.com> 于2020年9月1日周二 下午1:28写道:
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/usb/hcd-ehci.c | 2 ++
> hw/usb/hcd-xhci.c | 1 +
> 2 files changed, 3 insertions(+)
>
> diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
> index 2b995443fbfd..67847a9cf5f1 100644
> --- a/hw/usb/hcd-ehci.c
> +++ b/hw/usb/hcd-ehci.c
> @@ -1373,6 +1373,7 @@ static int ehci_execute(EHCIPacket *p, const char *action)
> usb_packet_setup(&p->packet, p->pid, ep, 0, p->qtdaddr, spd,
> (p->qtd.token & QTD_TOKEN_IOC) != 0);
Hi Gerd,
’usb_packet_setup‘ doesn't modify the 'iov' and other resources.
'usb_packet_cleanup' is paired with 'usb_packet_init' which I think should be
processed in the more up layer.
If 'usb_packet_map' fails, we need to clean the 'iov' in
'usb_packet_map' itself.
Thanks,
Li Qiang
> if (usb_packet_map(&p->packet, &p->sgl)) {
> + usb_packet_cleanup(&p->packet);
> qemu_sglist_destroy(&p->sgl);
> return -1;
> }
> @@ -1456,6 +1457,7 @@ static int ehci_process_itd(EHCIState *ehci,
> usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false,
> (itd->transact[i] & ITD_XACT_IOC) != 0);
> if (usb_packet_map(&ehci->ipacket, &ehci->isgl)) {
> + usb_packet_cleanup(&ehci->ipacket);
> qemu_sglist_destroy(&ehci->isgl);
> return -1;
> }
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index 46a2186d912a..9b156048920d 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -1616,6 +1616,7 @@ static int xhci_setup_packet(XHCITransfer *xfer)
> usb_packet_setup(&xfer->packet, dir, ep, xfer->streamid,
> xfer->trbs[0].addr, false, xfer->int_req);
> if (usb_packet_map(&xfer->packet, &xfer->sgl)) {
> + usb_packet_cleanup(&xfer->packet);
> qemu_sglist_destroy(&xfer->sgl);
> return -1;
> }
> --
> 2.27.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-01 9:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-01 5:27 [PATCH] usb: call usb_packet_cleanup on usb_packet_map failure Gerd Hoffmann
2020-09-01 9:33 ` Philippe Mathieu-Daudé
2020-09-01 9:51 ` Li Qiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).