diff options
author | Lin Ma <lma@suse.com> | 2018-06-11 17:23:05 +0800 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2018-06-15 10:39:53 +0800 |
commit | 8b43f964f987d44f25df1b7c002d0c241b57bffe (patch) | |
tree | a36280260e5cc80a8c333d46ac72adc6287f4f64 /net/net.c | |
parent | d542800d1edc62f63f8a29cfa6bdd1a9536ae11c (diff) | |
download | qemu-8b43f964f987d44f25df1b7c002d0c241b57bffe.zip qemu-8b43f964f987d44f25df1b7c002d0c241b57bffe.tar.gz qemu-8b43f964f987d44f25df1b7c002d0c241b57bffe.tar.bz2 |
net: Fix a potential segfault
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>
Diffstat (limited to 'net/net.c')
-rw-r--r-- | net/net.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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 { |