Skip to contentSkip to conversation

net: Fix a potential segfault

PATCH Superseded Lin Ma 2 participants 2 messages Jun 11, 2018 Networking

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lin Ma

author
#0 lore raw

PATCH 1/1 net: Fix a potential segfault

---
 net/net.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/net.c +6 -3
index efb9eaf779..f89790be4a 100644
@@ -1093,9 +1093,12 @@ 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"))) {
-        show_netdevs();
-        exit(0);
+    if (is_netdev) {
+        const char *type = qemu_opt_get(opts, "type");
+        if (type && is_help_option(type)) {
+            show_netdevs();
+            exit(0);
+        }
     } else {
         /* Parse convenience option format ip6-net=fec0::0[/64] */
         const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
Signature · 1 line
2.16.2
#1 lore raw
Quoted 4 lines · Lin Ma
---
 net/net.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Please provide a proper patch description: How can you provoke that segfault? (i.e. a set of command line options)

Thomas