Commit ab2da564d7f8f2a0e4e31875e1cdf87db14500e2

Authored by aurel32
1 parent 45f4d016

sh4: r2d fix no ide/net case

Fix invalid access/crash when there is no IDE device or NET device.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Tested-by: Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6673 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 5 additions and 5 deletions
hw/r2d.c
... ... @@ -224,13 +224,13 @@ static void r2d_init(ram_addr_t ram_size, int vga_ram_size,
224 224 serial_hds[2]);
225 225  
226 226 /* onboard CF (True IDE mode, Master only). */
227   - mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1,
228   - drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);
  227 + if ((i = drive_get_index(IF_IDE, 0, 0)) != -1)
  228 + mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1,
  229 + drives_table[i].bdrv, NULL);
229 230  
230 231 /* NIC: rtl8139 on-board, and 2 slots. */
231   - pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139");
232   - for (i = 1; i < nb_nics; i++)
233   - pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci");
  232 + for (i = 0; i < nb_nics; i++)
  233 + pci_nic_init(pci, &nd_table[i], (i==0)? 2<<3: -1, "rtl8139");
234 234  
235 235 /* Todo: register on board registers */
236 236 {
... ...