summaryrefslogtreecommitdiff
path: root/drivers/ide
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-07-28 05:29:56 +0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-07-30 09:26:53 +0400
commit9842727da7d95d8249087148048cc571f967c023 (patch)
tree0143e3f805a25c72a3f1d7301270720414d139c2 /drivers/ide
parent9ee07f91a1fab61ff0d8d25be43351a049c0a821 (diff)
downloadlinux-9842727da7d95d8249087148048cc571f967c023.tar.xz
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: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ppc/pmac.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index c521bf6e1bf2..fa2be26272d5 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -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 */
sanitize_timings(pmif);
+ host = ide_host_alloc(&d, hws);
+ if (host == NULL)
+ return -ENOMEM;
+ hwif = host->ports[0];
+
#ifndef CONFIG_PPC64
/* XXX FIXME: Media bay stuff need re-organizing */
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)
pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id,
pmif->mediabay ? " (mediabay)" : "", hw->irq);
- rc = ide_host_add(&d, hws, &host);
- if (rc)
+ rc = ide_host_register(host, &d, hws);
+ if (rc) {
+ ide_host_free(host);
return rc;
-
- hwif = host->ports[0];
+ }
return 0;
}