From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgHF0-0000Uc-ER for qemu-devel@nongnu.org; Thu, 09 Apr 2015 14:31:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YgHEv-00033Y-HQ for qemu-devel@nongnu.org; Thu, 09 Apr 2015 14:31:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YgHEv-00033O-8i for qemu-devel@nongnu.org; Thu, 09 Apr 2015 14:31:45 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t39IViXV019321 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 9 Apr 2015 14:31:44 -0400 Message-ID: <5526C58F.2050805@redhat.com> Date: Thu, 09 Apr 2015 12:31:43 -0600 From: Eric Blake MIME-Version: 1.0 References: <1428586365-17909-1-git-send-email-thuth@redhat.com> In-Reply-To: <1428586365-17909-1-git-send-email-thuth@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lVVNCRBjDHSLpnje5exQjtNsJCBHSPlan" Subject: Re: [Qemu-devel] [PATCH] Fix crash with illegal "-net nic, model=xxx" option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth , qemu-devel@nongnu.org Cc: jasowang@redhat.com, stefanha@redhat.com, mst@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lVVNCRBjDHSLpnje5exQjtNsJCBHSPlan Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/09/2015 07:32 AM, Thomas Huth wrote: > Current QEMU crashes when specifying an illegal model with the > "-net nic,model=3Dxxx" option, e.g.: >=20 > $ qemu-system-x86_64 -net nic,model=3Dn/a > qemu-system-x86_64: Unsupported NIC model: n/a >=20 > The problem is that pci_nic_init_nofail() does not check whether the er= r > parameter from pci_nic_init has been set up and thus passes a NULL poin= ter > to error_report_err(). Fix it by correctly checking the err parameter. >=20 > Signed-off-by: Thomas Huth > --- > hw/pci/pci.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 6941a82..b3d5100 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -1660,7 +1660,9 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBu= s *rootbus, > =20 > res =3D pci_nic_init(nd, rootbus, default_model, default_devaddr, = &err); > if (!res) { > - error_report_err(err); > + if (err) { > + error_report_err(err); > + } > exit(1); Doesn't this mean the program can exit without an error message, if pci_nic_init returns failure but failed to set err? Shouldn't you at least print something in that case as an else branch? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --lVVNCRBjDHSLpnje5exQjtNsJCBHSPlan Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVJsWPAAoJEKeha0olJ0Nq0p4H/iWib1w/tvqlUl2eZ0T9TNCQ EbJTy/9xe/9oE+5vsOXbOxIFY6q9HwZLQaM7DGc/5og//Xfc754R9d3ZdS/Eqoza IMwoZY+P5Wd+maPu0ICoijGDp7sgpmlh1Ub7mt6XD9B97NKwZtcL7h7LMUfD6MJy fD49jNu1M/uavbaWyjfw3pbMYNvsMibnaD160a8vqP2hr+KYi30sVMu4NFPkLeun UolIx6dHh3k6jGSXdPCs7T+xC8pppCd1uaobSFKPqiNJxCB5AQllRpHdMLZWHVWO XenMqcOnjt9rHIFLK5GWiOWkuoSINTJ0TA2Z9roBO3i3BFk/ZTzmFe3duL2+/QA= =3IgV -----END PGP SIGNATURE----- --lVVNCRBjDHSLpnje5exQjtNsJCBHSPlan--