qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Richard Henderson" <rth@twiddle.net>,
	qemu-arm@nongnu.org, "Li Zhijian" <lizhijian@cn.fujitsu.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
	"Zhang Chen" <zhangckid@gmail.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Corey Minyard" <minyard@acm.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [Qemu-devel] [PULL 3/8] usb/dev-mtp: Fix use of uninitialized values
Date: Tue, 12 Jun 2018 12:44:25 +0200	[thread overview]
Message-ID: <20180612104430.25745-4-kraxel@redhat.com> (raw)
In-Reply-To: <20180612104430.25745-1-kraxel@redhat.com>

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

This fixes:

  hw/usb/dev-mtp.c:971:5: warning: 4th function call argument is an uninitialized value
      trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path,
                                           c->argv[1], c->argv[2]);
                                                       ^~~~~~~~~~
and:

  hw/usb/dev-mtp.c:981:12: warning: Assigned value is garbage or undefined
      offset = c->argv[1];
               ^ ~~~~~~~~~~

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20180604151421.23385-3-f4bug@amsat.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb/dev-mtp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 560c61c7c1..b0ab6a7912 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1017,12 +1017,16 @@ static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c,
 static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c,
                                            MTPObject *o)
 {
-    MTPData *d = usb_mtp_data_alloc(c);
+    MTPData *d;
     off_t offset;
 
+    if (c->argc <= 2) {
+        return NULL;
+    }
     trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path,
                                         c->argv[1], c->argv[2]);
 
+    d = usb_mtp_data_alloc(c);
     d->fd = open(o->path, O_RDONLY);
     if (d->fd == -1) {
         usb_mtp_data_free(d);
-- 
2.9.3

  parent reply	other threads:[~2018-06-12 10:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 10:44 [Qemu-devel] [PULL 0/8] Usb 20180612 patches Gerd Hoffmann
2018-06-12 10:44 ` [Qemu-devel] [PULL 1/8] usb: update docs Gerd Hoffmann
2018-06-12 10:44 ` [Qemu-devel] [PULL 2/8] usb: correctly handle Zero Length Packets Gerd Hoffmann
2018-06-12 10:44 ` Gerd Hoffmann [this message]
2018-06-12 10:44 ` [Qemu-devel] [PULL 4/8] bus: do not unref the added child bus on realize Gerd Hoffmann
2018-06-13 16:05   ` Paolo Bonzini
2018-06-13 16:21     ` Marc-André Lureau
2018-06-12 10:44 ` [Qemu-devel] [PULL 5/8] object: fix OBJ_PROP_LINK_UNREF_ON_RELEASE ambivalence Gerd Hoffmann
2018-06-13 16:14   ` Paolo Bonzini
2018-06-12 10:44 ` [Qemu-devel] [PULL 6/8] usb-ccid: fix bus leak Gerd Hoffmann
2018-06-13 16:16   ` Paolo Bonzini
2018-06-12 10:44 ` [Qemu-devel] [PULL 7/8] usb-hcd-xhci-test: add a test for ccid hotplug Gerd Hoffmann
2018-06-12 10:44 ` [Qemu-devel] [PULL 8/8] usb-mtp: Return error on suspicious TYPE_DATA packet from initiator Gerd Hoffmann
2018-06-12 15:42 ` [Qemu-devel] [PULL 0/8] Usb 20180612 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=20180612104430.25745-4-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=afaerber@suse.de \
    --cc=alistair@alistair23.me \
    --cc=crosthwaite.peter@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jasowang@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=minyard@acm.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=zhangckid@gmail.com \
    /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).