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>
This commit is contained in:
Bandan Das 2018-05-03 15:20:28 -04:00 committed by Gerd Hoffmann
parent 24e8d1faea
commit 2392ae6bbb

View File

@ -1948,16 +1948,17 @@ static void usb_mtp_realize(USBDevice *dev, Error **errp)
return; return;
} }
s->desc = strrchr(s->root, '/'); s->desc = strrchr(s->root, '/');
/* Mark store as RW */
if (!s->readonly) {
s->flags |= (1 << MTP_FLAG_WRITABLE);
}
if (s->desc && s->desc[0]) { if (s->desc && s->desc[0]) {
s->desc = g_strdup(s->desc + 1); s->desc = g_strdup(s->desc + 1);
} else { } else {
s->desc = g_strdup("none"); s->desc = g_strdup("none");
} }
} }
/* Mark store as RW */
if (!s->readonly) {
s->flags |= (1 << MTP_FLAG_WRITABLE);
}
} }
static const VMStateDescription vmstate_usb_mtp = { static const VMStateDescription vmstate_usb_mtp = {