From patchwork Tue Mar 22 18:21:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 738 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:45:18 -0000 Delivered-To: patches@linaro.org Received: by 10.204.113.5 with SMTP id y5cs9382bkp; Tue, 22 Mar 2011 11:22:02 -0700 (PDT) Received: by 10.227.72.7 with SMTP id k7mr1235501wbj.115.1300818121960; Tue, 22 Mar 2011 11:22:01 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id b20si11619200wbe.58.2011.03.22.11.22.00 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Mar 2011 11:22:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1Q26DO-00026E-Fx; Tue, 22 Mar 2011 18:21:58 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH] hw/versatilepb, realview: Fix condition for instantiation of onboard NIC Date: Tue, 22 Mar 2011 18:21:58 +0000 Message-Id: <1300818118-8047-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.3 Correct the condition determining whether we instantiate the onboard NIC or a PCI card NIC on VersatilePB and Realview boards. This was broken in two ways: (1) if the user asked for two default NICs ("-net nic -net nic") we would crash trying to strcmp() a NULL pointer (2) if the user asked for two NICs explicitly of the same model as the onboard NIC (eg "-net nic,model=smc91c111 -net nic,model=smc91c111") we would try to instantiate two onboard NICs at the same address. Signed-off-by: Peter Maydell --- hw/realview.c | 4 ++-- hw/versatilepb.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/realview.c b/hw/realview.c index a67861e..96fb9da 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -288,8 +288,8 @@ static void realview_init(ram_addr_t ram_size, for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; - if ((!nd->model && !done_nic) - || strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0) { + if (!done_nic && (!nd->model || + strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) { if (is_pb) { lan9118_init(nd, 0x4e000000, pic[28]); } else { diff --git a/hw/versatilepb.c b/hw/versatilepb.c index 9f1bfcf..46b6a3f 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -223,7 +223,7 @@ static void versatile_init(ram_addr_t ram_size, for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; - if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) { + if (!done_smc && (!nd->model || strcmp(nd->model, "smc91c111") == 0)) { smc91c111_init(nd, 0x10010000, sic[25]); done_smc = 1; } else {