From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>, Bandan Das <bsd@redhat.com>
Subject: [Qemu-devel] [PULL 1/3] usb-mtp: Add some NULL checks for issues pointed out by coverity
Date: Mon, 7 May 2018 11:44:46 +0200 [thread overview]
Message-ID: <20180507094448.32386-2-kraxel@redhat.com> (raw)
In-Reply-To: <20180507094448.32386-1-kraxel@redhat.com>
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>
Message-id: 20180503192028.14353-2-bsd@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@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.9.3
next prev parent reply other threads:[~2018-05-07 9:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-07 9:44 [Qemu-devel] [PULL 0/3] Usb 20180507 patches Gerd Hoffmann
2018-05-07 9:44 ` Gerd Hoffmann [this message]
2018-05-15 18:50 ` [Qemu-devel] [PULL 1/3] usb-mtp: Add some NULL checks for issues pointed out by coverity Peter Maydell
2018-05-17 21:41 ` Bandan Das
2018-05-18 18:22 ` [Qemu-devel] [PATCH] usb-mtp: Assert on suspicious TYPE_DATA packet from initiator Bandan Das
2018-05-18 18:25 ` Peter Maydell
2018-05-18 18:38 ` Bandan Das
2018-05-18 18:49 ` Peter Maydell
2018-05-18 19:04 ` Bandan Das
2018-05-18 18:49 ` [Qemu-devel] [PATCH v2] usb-mtp: Return error " Bandan Das
2018-05-18 18:25 ` [Qemu-devel] [PULL 1/3] usb-mtp: Add some NULL checks for issues pointed out by coverity Bandan Das
2018-05-07 9:44 ` [Qemu-devel] [PULL 2/3] usb-mtp: Unconditionally check for the readonly bit Gerd Hoffmann
2018-05-07 9:44 ` [Qemu-devel] [PULL 3/3] usb-host: skip open on pending postload bh Gerd Hoffmann
2018-05-08 13:22 ` [Qemu-devel] [PULL 0/3] Usb 20180507 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180507094448.32386-2-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=bsd@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).