[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 9/9] usb: mtp: reply INCOMPLETE_TRANSFER on read
From: |
Peter Wu |
Subject: |
Re: [Qemu-devel] [PATCH 9/9] usb: mtp: reply INCOMPLETE_TRANSFER on read errors |
Date: |
Fri, 25 Apr 2014 13:20:36 +0200 |
User-agent: |
KMail/4.13 (Linux/3.15.0-rc1-custom-00356-gebfc45e; KDE/4.13.0; x86_64; ; ) |
On Friday 25 April 2014 12:48:14 Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <address@hidden>
> ---
> hw/usb/dev-mtp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
> index 6bd6a82..8e1a1b7 100644
> --- a/hw/usb/dev-mtp.c
> +++ b/hw/usb/dev-mtp.c
> @@ -50,6 +50,7 @@ enum mtp_code {
> RES_INVALID_TRANSACTION_ID = 0x2004,
> RES_OPERATION_NOT_SUPPORTED = 0x2005,
> RES_PARAMETER_NOT_SUPPORTED = 0x2006,
> + RES_INCOMPLETE_TRANSFER = 0x2007,
> RES_INVALID_STORAGE_ID = 0x2008,
> RES_INVALID_OBJECT_HANDLE = 0x2009,
> RES_SPEC_BY_FORMAT_UNSUPPORTED = 0x2014,
> @@ -946,7 +947,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket
> *p) }
> rc = read(d->fd, d->data, dlen);
> if (rc != dlen) {
> - fprintf(stderr, "%s: TODO: handle read error\n",
> __func__);
> + s->result->code = RES_INCOMPLETE_TRANSFER;
> }
> usb_packet_copy(p, d->data, dlen);
> }
The bogus data packet is sent with usb_packet_copy, shouldn't you return
USB_RET_NAK for now? Something like:
if (rc == dlen) {
usb_packet_copy(p, d->data, dlen);
} else {
s->result->code = RES_INCOMPLETE_TRANSFER;
dlen = 0;
}
dlen = 0 to avoid messing with the offset.
Kind regards,
Peter
- [Qemu-devel] [PATCH 0/9] usb: mtp: a bunch of fixes, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 2/9] usb: mtp: fix usb_mtp_add_u64, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 1/9] usb: mtp: replace debug printfs with trace points, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 7/9] usb: mtp: avoid empty description string, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 9/9] usb: mtp: reply INCOMPLETE_TRANSFER on read errors, Gerd Hoffmann, 2014/04/25
- Re: [Qemu-devel] [PATCH 9/9] usb: mtp: reply INCOMPLETE_TRANSFER on read errors,
Peter Wu <=
- [Qemu-devel] [PATCH 5/9] usb: mtp: fix error path memory leak, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 8/9] usb: mtp: drop data-out hexdump, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 6/9] usb: mtp: fix possible buffer overflow, Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 3/9] usb: mtp: fix version (is decimal not bcd), Gerd Hoffmann, 2014/04/25
- [Qemu-devel] [PATCH 4/9] usb: mtp: fix serial (must be exact 32 chars), Gerd Hoffmann, 2014/04/25
- Re: [Qemu-devel] [PATCH 0/9] usb: mtp: a bunch of fixes, Peter Wu, 2014/04/25