All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Lin Ma <lma@suse.com>,
	qemu-stable@nongnu.org, Jason Wang <jasowang@redhat.com>
Subject: [Qemu-devel] [PULL 2/4] net: Fix a potential segfault
Date: Fri, 15 Jun 2018 11:01:21 +0800	[thread overview]
Message-ID: <1529031683-27458-3-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1529031683-27458-1-git-send-email-jasowang@redhat.com>

From: Lin Ma <lma@suse.com>

If user forgets to provide any backend types for '-netdev' in qemu CLI,
It triggers seg fault.

e.g.

Expected:
$ qemu -netdev id=net0
qemu-system-x86_64: Parameter 'type' is missing

Actual:
$ qemu -netdev id=net0
Segmentation fault (core dumped)

Fixes: 547203ead4327 ("net: List available netdevs with "-netdev help")
Reviewed-by: Thomas Huth <thuth@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net/net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index efb9eaf..2a31339 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1093,7 +1093,9 @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
     int ret = -1;
     Visitor *v = opts_visitor_new(opts);
 
-    if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) {
+    const char *type = qemu_opt_get(opts, "type");
+
+    if (is_netdev && type && is_help_option(type)) {
         show_netdevs();
         exit(0);
     } else {
-- 
2.7.4

  parent reply	other threads:[~2018-06-15  3:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  3:01 [Qemu-devel] [PULL 0/4] Net patches Jason Wang
2018-06-15  3:01 ` [Qemu-devel] [PULL 1/4] tap: set vhostfd passed from qemu cli to non-blocking Jason Wang
2018-06-15  3:01 ` Jason Wang [this message]
2018-06-15  3:01 ` [Qemu-devel] [PULL 3/4] e1000e: Do not auto-clear ICR bits which aren't set in EIAC Jason Wang
2018-06-15  3:01 ` [Qemu-devel] [PULL 4/4] vhost-user: delete net client if necessary Jason Wang
2018-06-15 11:49 ` [Qemu-devel] [PULL 0/4] Net 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=1529031683-27458-3-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=lma@suse.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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 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.