qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <weil@mail.berlios.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [BUG][PATCH] Fix a nullpointer crash caused by r6216
Date: Sun, 11 Jan 2009 19:55:39 +0100	[thread overview]
Message-ID: <496A40AB.1030607@mail.berlios.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

Hi,

this patch tries to fix a nullpointer crash caused by r6216 (nd->model
needs value != NULL).
See also http://lists.gnu.org/archive/html/qemu-devel/2009-01/msg00257.html.

mips-r4k.c was already fixed but now contained a copy-paste bug (index i
is wrong here).

Regards
Stefan Weil



[-- Attachment #2: fixmodel.patch --]
[-- Type: text/x-diff, Size: 3839 bytes --]

fix nullpointer crash caused by r6216 (nd->model needs value != NULL)
mips-r4k.c was already fixed but now contained a copy-paste bug

Signed-off-by: Stefan Weil <weil@mail.berlios.de>

Index: trunk/hw/integratorcp.c
===================================================================
--- trunk.orig/hw/integratorcp.c	2009-01-11 19:40:41.000000000 +0100
+++ trunk/hw/integratorcp.c	2009-01-11 19:40:49.000000000 +0100
@@ -498,8 +498,10 @@
     }
     pl181_init(0x1c000000, drives_table[sd].bdrv, pic[23], pic[24]);
     if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "smc91c111") == 0) {
+        if (nd_table[0].model == NULL) {
+            nd_table[0].model = "smc91c111";
+        }
+        if (strcmp(nd_table[0].model, "smc91c111") == 0) {
             smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
         } else if (strcmp(nd_table[0].model, "?") == 0) {
             fprintf(stderr, "qemu: Supported NICs: smc91c111\n");
Index: trunk/hw/mcf5208.c
===================================================================
--- trunk.orig/hw/mcf5208.c	2009-01-11 19:40:41.000000000 +0100
+++ trunk/hw/mcf5208.c	2009-01-11 19:40:49.000000000 +0100
@@ -242,8 +242,10 @@
         exit(1);
     }
     if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "mcf_fec") == 0) {
+        if (nd_table[0].model == NULL) {
+            nd_table[0].model = "mcf_fec";
+        }
+        if (strcmp(nd_table[0].model, "mcf_fec") == 0) {
             mcf_fec_init(&nd_table[0], 0xfc030000, pic + 36);
         } else if (strcmp(nd_table[0].model, "?") == 0) {
             fprintf(stderr, "qemu: Supported NICs: mcf_fec\n");
Index: trunk/hw/mips_mipssim.c
===================================================================
--- trunk.orig/hw/mips_mipssim.c	2009-01-11 19:40:41.000000000 +0100
+++ trunk/hw/mips_mipssim.c	2009-01-11 19:40:49.000000000 +0100
@@ -176,8 +176,10 @@
         serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]);
 
     if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "mipsnet") == 0) {
+        if (nd_table[0].model == NULL) {
+            nd_table[0].model = "mipsnet";
+        }
+        if (strcmp(nd_table[0].model, "mipsnet") == 0) {
             /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
             mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
         } else if (strcmp(nd_table[0].model, "?") == 0) {
Index: trunk/hw/mips_r4k.c
===================================================================
--- trunk.orig/hw/mips_r4k.c	2009-01-11 19:40:41.000000000 +0100
+++ trunk/hw/mips_r4k.c	2009-01-11 19:40:49.000000000 +0100
@@ -248,8 +248,8 @@
                  vga_ram_size);
 
     if (nd_table[0].vlan) {
-        if (nd_table[i].model == NULL) {
-	    nd_table[i].model = "ne2k_isa";
+        if (nd_table[0].model == NULL) {
+            nd_table[0].model = "ne2k_isa";
         }
         if (strcmp(nd_table[0].model, "ne2k_isa") == 0) {
             isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
Index: trunk/hw/r2d.c
===================================================================
--- trunk.orig/hw/r2d.c	2009-01-11 19:47:36.000000000 +0100
+++ trunk/hw/r2d.c	2009-01-11 19:52:59.000000000 +0100
@@ -230,9 +230,13 @@
         drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);
 
     /* NIC: rtl8139 on-board, and 2 slots. */
+    nd_table[0].model = "rtl8139";
     pci_rtl8139_init(pci, &nd_table[0], 2 << 3);
-    for (i = 1; i < nb_nics; i++)
-        pci_nic_init(pci, &nd_table[i], -1);
+    for (i = 1; i < nb_nics; i++) {
+        if (nd_table[i].model != NULL) {
+            pci_nic_init(pci, &nd_table[i], -1);
+        }
+    }
 
     /* Todo: register on board registers */
     {

             reply	other threads:[~2009-01-11 18:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-11 18:55 Stefan Weil [this message]
2009-01-11 19:29 ` [Qemu-devel] [BUG][PATCH] Fix a nullpointer crash caused by r6216 Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=496A40AB.1030607@mail.berlios.de \
    --to=weil@mail.berlios.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).