aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/dev-mtp.c
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2018-05-03 15:20:27 -0400
committerGerd Hoffmann <kraxel@redhat.com>2018-05-07 11:10:25 +0200
commit24e8d1faea1e4a2dc59841e048390645d7804cb5 (patch)
tree30e5608632325af87d9dd3ac2d3eb288a3434f7f /hw/usb/dev-mtp.c
parentc8b7e627b4269a3bc3ae41d9f420547a47e6d9b9 (diff)
usb-mtp: Add some NULL checks for issues pointed out by coverity
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> Message-id: 20180503192028.14353-2-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.c6
1 files 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));