summary refs log tree commit diff stats
path: root/hw/usb/dev-mtp.c
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2018-05-03 15:20:28 -0400
committerGerd Hoffmann <kraxel@redhat.com>2018-05-07 11:10:25 +0200
commit2392ae6bbb0a940a4fd6df29e704b09cadc14790 (patch)
tree99d43ff4fb288ba21adf7f3bd08961ed89d86e62 /hw/usb/dev-mtp.c
parent24e8d1faea1e4a2dc59841e048390645d7804cb5 (diff)
downloadfocaccia-qemu-2392ae6bbb0a940a4fd6df29e704b09cadc14790.tar.gz
focaccia-qemu-2392ae6bbb0a940a4fd6df29e704b09cadc14790.zip
usb-mtp: Unconditionally check for the readonly bit
Currently, it's only being checked if desc is NULL and
so write support breaks upon specifying desc

Signed-off-by: Bandan Das <bsd@redhat.com>
Message-id: 20180503192028.14353-3-bsd@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/dev-mtp.c')
-rw-r--r--hw/usb/dev-mtp.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 24cff640c0..3d59fe4944 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1948,16 +1948,17 @@ static void usb_mtp_realize(USBDevice *dev, Error **errp)
             return;
         }
         s->desc = strrchr(s->root, '/');
-        /* Mark store as RW */
-        if (!s->readonly) {
-            s->flags |= (1 << MTP_FLAG_WRITABLE);
-        }
         if (s->desc && s->desc[0]) {
             s->desc = g_strdup(s->desc + 1);
         } else {
             s->desc = g_strdup("none");
         }
     }
+    /* Mark store as RW */
+    if (!s->readonly) {
+        s->flags |= (1 << MTP_FLAG_WRITABLE);
+    }
+
 }
 
 static const VMStateDescription vmstate_usb_mtp = {