summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorBandan2018-09-08 00:08:49 +0200
committerGerd Hoffmann2018-10-01 10:49:53 +0200
commit44dd4196806ef015e7df3c671ca986b0b5ca0f73 (patch)
tree108837fb263ad8a854c4cff0654b5fe03cc4ceeb /hw
parentMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180926' into staging (diff)
downloadqemu-44dd4196806ef015e7df3c671ca986b0b5ca0f73.tar.gz
qemu-44dd4196806ef015e7df3c671ca986b0b5ca0f73.tar.xz
qemu-44dd4196806ef015e7df3c671ca986b0b5ca0f73.zip
usb-mtp: fix error conditions for write operation
Return STORE_FULL if we can't write all the bytes but return incomplete transfer if data received is less then what was specified in the metadata. Also, use d->offset as the file size which is valid for all file sizes. Signed-off-by: Bandan <bsd@redhat.com> Message-id: 20180907220851.9658-2-bsd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/usb/dev-mtp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 3fdc4b0da1..15edf3bb82 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1665,13 +1665,14 @@ static void usb_mtp_write_data(MTPState *s)
goto success;
}
- rc = write_retry(d->fd, d->data, s->dataset.size);
- if (!rc) {
+ rc = write_retry(d->fd, d->data, d->offset);
+ if (rc != d->offset) {
usb_mtp_queue_result(s, RES_STORE_FULL, d->trans,
0, 0, 0, 0);
goto done;
}
- if (rc != s->dataset.size) {
+ /* Only for < 4G file sizes */
+ if (s->dataset.size != 0xFFFFFFFF && rc != s->dataset.size) {
usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans,
0, 0, 0, 0);
goto done;