qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] net: Fix a potential segfault


From: Jason Wang
Subject: Re: [Qemu-devel] [PATCH v3] net: Fix a potential segfault
Date: Tue, 12 Jun 2018 10:03:47 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0



On 2018年06月11日 17:48, Thomas Huth wrote:
On 11.06.2018 11:23, Lin Ma wrote:
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)

Signed-off-by: Lin Ma <address@hidden>
---
  net/net.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/net.c b/net/net.c
index efb9eaf779..2a3133990c 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 {

Reviewed-by: Thomas Huth <address@hidden>

Applied, and queued for -stable.

Thanks




reply via email to

[Prev in Thread] Current Thread [Next in Thread]