All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] Minor MTP fixes
@ 2018-05-03 19:20 Bandan
  2018-05-03 19:20 ` [Qemu-devel] [PATCH 1/2] usb-mtp: Add some NULL checks for issues pointed out by coverity Bandan
  2018-05-03 19:20 ` [Qemu-devel] [PATCH 2/2] usb-mtp: Unconditionally check for the readonly bit Bandan
  0 siblings, 2 replies; 3+ messages in thread
From: Bandan @ 2018-05-03 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

Minor MTP fixes. The first patch adds some checks/asserts for issues
reported by Coverity and the second fixes a bug where the readonly flag
is ignored if "desc" is specified.

Bandan Das (2):
  usb-mtp: Add some NULL checks for issues pointed out by coverity
  usb-mtp: Unconditionally check for the readonly bit

 hw/usb/dev-mtp.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 1/2] usb-mtp: Add some NULL checks for issues pointed out by coverity
  2018-05-03 19:20 [Qemu-devel] [PATCH 0/2] Minor MTP fixes Bandan
@ 2018-05-03 19:20 ` Bandan
  2018-05-03 19:20 ` [Qemu-devel] [PATCH 2/2] usb-mtp: Unconditionally check for the readonly bit Bandan
  1 sibling, 0 replies; 3+ messages in thread
From: Bandan @ 2018-05-03 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

From: Bandan Das <bsd@redhat.com>

CID 1390578: In usb_mtp_write_metadata, parent can never be NULL but
just in case, add an assert
CID 1390592: Check for o->format only if o !=NULL
CID 1390604: Check s->data_out != NULL in usb_mtp_handle_data

Signed-off-by: Bandan Das <bsd@redhat.com>
---
 hw/usb/dev-mtp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 6ecf70a79b..24cff640c0 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1446,8 +1446,7 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
             if (o == NULL) {
                 usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans,
                                      0, 0, 0, 0);
-            }
-            if (o->format != FMT_ASSOCIATION) {
+            } else if (o->format != FMT_ASSOCIATION) {
                 usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT, c->trans,
                                      0, 0, 0, 0);
             }
@@ -1660,6 +1659,7 @@ static void usb_mtp_write_metadata(MTPState *s)
     uint32_t next_handle = s->next_handle;
 
     assert(!s->write_pending);
+    assert(p != NULL);
 
     utf16_to_str(dataset->length, dataset->filename, filename);
 
@@ -1838,7 +1838,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p)
             p->status = USB_RET_STALL;
             return;
         }
-        if (s->data_out && !s->data_out->first) {
+        if ((s->data_out != NULL) && !s->data_out->first) {
             container_type = TYPE_DATA;
         } else {
             usb_packet_copy(p, &container, sizeof(container));
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 2/2] usb-mtp: Unconditionally check for the readonly bit
  2018-05-03 19:20 [Qemu-devel] [PATCH 0/2] Minor MTP fixes Bandan
  2018-05-03 19:20 ` [Qemu-devel] [PATCH 1/2] usb-mtp: Add some NULL checks for issues pointed out by coverity Bandan
@ 2018-05-03 19:20 ` Bandan
  1 sibling, 0 replies; 3+ messages in thread
From: Bandan @ 2018-05-03 19:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: kraxel

From: Bandan Das <bsd@redhat.com>

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>
---
 hw/usb/dev-mtp.c | 9 +++++----
 1 file 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 = {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-03 19:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 19:20 [Qemu-devel] [PATCH 0/2] Minor MTP fixes Bandan
2018-05-03 19:20 ` [Qemu-devel] [PATCH 1/2] usb-mtp: Add some NULL checks for issues pointed out by coverity Bandan
2018-05-03 19:20 ` [Qemu-devel] [PATCH 2/2] usb-mtp: Unconditionally check for the readonly bit Bandan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.