ide/powermac: Fix use of uninitialized pointer on media-bay

The current ide-pmac calls media_bay_set_ide_infos() with an
uninitialized "hwif" argument. The proper fix is to split the
allocation of the hwif from its registration in order to properly
setup the mediabay informations before registration.
Acked-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 9ee07f91
...@@ -1086,6 +1086,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) ...@@ -1086,6 +1086,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
/* Make sure we have sane timings */ /* Make sure we have sane timings */
sanitize_timings(pmif); sanitize_timings(pmif);
host = ide_host_alloc(&d, hws);
if (host == NULL)
return -ENOMEM;
hwif = host->ports[0];
#ifndef CONFIG_PPC64 #ifndef CONFIG_PPC64
/* XXX FIXME: Media bay stuff need re-organizing */ /* XXX FIXME: Media bay stuff need re-organizing */
if (np->parent && np->parent->name if (np->parent && np->parent->name
...@@ -1119,11 +1124,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw) ...@@ -1119,11 +1124,11 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id,
pmif->mediabay ? " (mediabay)" : "", hw->irq); pmif->mediabay ? " (mediabay)" : "", hw->irq);
rc = ide_host_add(&d, hws, &host); rc = ide_host_register(host, &d, hws);
if (rc) if (rc) {
ide_host_free(host);
return rc; return rc;
}
hwif = host->ports[0];
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment