* [Qemu-devel] [PATCH] hw/versatilepb, realview: Fix condition for instantiation of onboard NIC
@ 2011-03-22 18:21 Peter Maydell
2011-04-01 20:42 ` Aurelien Jarno
0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2011-03-22 18:21 UTC (permalink / raw)
To: qemu-devel; +Cc: patches
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 <peter.maydell@linaro.org>
---
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 {
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/versatilepb, realview: Fix condition for instantiation of onboard NIC
2011-03-22 18:21 [Qemu-devel] [PATCH] hw/versatilepb, realview: Fix condition for instantiation of onboard NIC Peter Maydell
@ 2011-04-01 20:42 ` Aurelien Jarno
0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2011-04-01 20:42 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, patches
On Tue, Mar 22, 2011 at 06:21:58PM +0000, Peter Maydell wrote:
> 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 <peter.maydell@linaro.org>
> ---
> hw/realview.c | 4 ++--
> hw/versatilepb.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
Thanks, applied.
> 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 {
> --
> 1.7.1
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-04-01 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-22 18:21 [Qemu-devel] [PATCH] hw/versatilepb, realview: Fix condition for instantiation of onboard NIC Peter Maydell
2011-04-01 20:42 ` Aurelien Jarno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).