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>
This commit is contained in:
parent
c8b7e627b4
commit
24e8d1faea
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user