]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
usb-mtp: handle lseek failure
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 20 May 2014 11:02:26 +0000 (13:02 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 26 May 2014 06:41:07 +0000 (08:41 +0200)
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-mtp.c

index c2750e4bd20fa757002ed7281aa463c23213e1a9..a95298bd3402921d6ecf1427f9d7e6604c709679 100644 (file)
@@ -702,7 +702,10 @@ static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c,
     if (offset > o->stat.st_size) {
         offset = o->stat.st_size;
     }
-    lseek(d->fd, offset, SEEK_SET);
+    if (lseek(d->fd, offset, SEEK_SET) < 0) {
+        usb_mtp_data_free(d);
+        return NULL;
+    }
 
     d->length = c->argv[2];
     if (d->length > o->stat.st_size - offset) {