From nobody Sat Apr 27 16:39:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528709197468299.1779126488856; Mon, 11 Jun 2018 02:26:37 -0700 (PDT) Received: from localhost ([::1]:47321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSJ5o-00071g-2j for importer@patchew.org; Mon, 11 Jun 2018 05:26:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSJ4x-0006eP-MO for qemu-devel@nongnu.org; Mon, 11 Jun 2018 05:25:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSJ4u-0008K2-FT for qemu-devel@nongnu.org; Mon, 11 Jun 2018 05:25:35 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:39318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSJ4u-0008Jk-Ai for qemu-devel@nongnu.org; Mon, 11 Jun 2018 05:25:32 -0400 Received: by mail-pf0-x242.google.com with SMTP id r11-v6so9918593pfl.6 for ; Mon, 11 Jun 2018 02:25:32 -0700 (PDT) Received: from localhost.localdomain ([45.122.156.254]) by smtp.gmail.com with ESMTPSA id k80-v6sm93229545pfa.168.2018.06.11.02.25.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 02:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=t6DxS9taGDEc3xiR63jLn0QC41sjRJ6FgrGnetJRBj4=; b=nkDcW5Z127qDbDUeTUHAvD3ctTpK9DoSDC4NYqA0714tozV6hwyGx5Osp/fzxOM244 aEvvzTQShoqUZkdlks3g8V5zEDolpmoqpD4/wvtJqK1LMTP1UWDSXmIgz1UFC4ZWjFXQ 9acM1OEbrb8C8qKNUPH82bkzqNU9J1FvS551vEJT0oK+HN8aqP43lqqKyDTDqMyWwi1O sPuZNZTB/MArkheoC8Cy2JtvH21U1M8hOAe9xeSnJzEYWgE0vIXV3+XuM59RHJOFnUUJ DZGv+SYFUuDddNNWzKwzY7zuKbDIPrJpEe7u8Rv1PCY+h5V/Wl/Bio0zn44zShlAryWm 6oIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=t6DxS9taGDEc3xiR63jLn0QC41sjRJ6FgrGnetJRBj4=; b=fm4Dvz4TzuQLJ1O5ZRlr4bY+6XczGIyy6fWLkOudeg0Vx6rzGiNxFoKopPyBXJSy+z YeRFaMgGv68rW+dP82ubEfUm1zUALLCMnd2sEqz1rmfN2CZZvhG/afz55r4o2vW+OW6M c3jhpj0w/TMrOyfnP5juUOSFZSHumq11s/PwLh6w0171hMmEwyYLxVEsnqDM4WZusB32 CCiCg0l+DcLVv4lVPNUntTp7+bkQ/4eLV4PhMm4PX3yMbD3xW0V0qcMaggWc3Q87LDFW pzEE/QUJWwH6EG48cKvuNcqT1w7V4e2LeuHmlnB8fKodnnO0aLrWqtfWeK5iXwZ1b37g 9ybA== X-Gm-Message-State: APt69E3ZJP5VVBDaefJ0tQpqNP07NLE0lgMe73z6SbimYQEb4Vpb5/GK Y7YIsmBYCNaMjTnaE2KZdFzWqQ== X-Google-Smtp-Source: ADUXVKIOj3Hj+nfsibP+MCw/5BqaM4QQCZ8+O/myN6BbCJ+NokXUzAUKeilmX5ixKW1oGeG0MDD8Vg== X-Received: by 2002:a65:4b04:: with SMTP id r4-v6mr11373929pgq.26.1528709130960; Mon, 11 Jun 2018 02:25:30 -0700 (PDT) From: Lin Ma To: qemu-devel@nongnu.org Date: Mon, 11 Jun 2018 17:23:05 +0800 Message-Id: <20180611092305.2542-1-lma@suse.com> X-Mailer: git-send-email 2.15.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3] net: Fix a potential segfault X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, jasowang@redhat.com, Lin Ma Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If user forgets to provide any backend types for '-netdev' in qemu CLI, It triggers seg fault. e.g. Expected: $ qemu -netdev id=3Dnet0 qemu-system-x86_64: Parameter 'type' is missing Actual: $ qemu -netdev id=3Dnet0 Segmentation fault (core dumped) Signed-off-by: Lin Ma Reviewed-by: Thomas Huth --- 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_ne= tdev, Error **errp) int ret =3D -1; Visitor *v =3D opts_visitor_new(opts); =20 - if (is_netdev && is_help_option(qemu_opt_get(opts, "type"))) { + const char *type =3D qemu_opt_get(opts, "type"); + + if (is_netdev && type && is_help_option(type)) { show_netdevs(); exit(0); } else { --=20 2.16.2