aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorElias Oltmanns <eo@nebensachen.de>2008-10-13 15:39:45 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:45 -0400
commite415e495f8294e536e09e6a15fba897cce4c0748 (patch)
tree7a1a9c82d1b0faedf2454a76027df6e1fff4a8fb /drivers/ide/ide-probe.c
parent06b89518fa69fb7243dc98c31f9a9cfa61bfe788 (diff)
ide: Two fixes regarding memory allocation
In function ide_devset_execute() we should use __GFP_WAIT rather than GFP_KERNEL. Also, the allocation cannot possibly fail at that point. More importantly, there is a potential memory leak in the device probing code. The infrastructure seems rather complex and I hope I haven't messed anything up by trying to fix this. Signed-off-by: Elias Oltmanns <eo@nebensachen.de> [bart: remove superfluous ide_lock taking] Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index bce427ee08aa..de8edd306c79 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -958,9 +958,9 @@ static void ide_add_drive_to_hwgroup(ide_drive_t *drive)
958 * - allocate the block device queue 958 * - allocate the block device queue
959 * - link drive into the hwgroup 959 * - link drive into the hwgroup
960 */ 960 */
961static void ide_port_setup_devices(ide_hwif_t *hwif) 961static int ide_port_setup_devices(ide_hwif_t *hwif)
962{ 962{
963 int i; 963 int i, j = 0;
964 964
965 mutex_lock(&ide_cfg_mtx); 965 mutex_lock(&ide_cfg_mtx);
966 for (i = 0; i < MAX_DRIVES; i++) { 966 for (i = 0; i < MAX_DRIVES; i++) {
@@ -972,12 +972,19 @@ static void ide_port_setup_devices(ide_hwif_t *hwif)
972 if (ide_init_queue(drive)) { 972 if (ide_init_queue(drive)) {
973 printk(KERN_ERR "ide: failed to init %s\n", 973 printk(KERN_ERR "ide: failed to init %s\n",
974 drive->name); 974 drive->name);
975 kfree(drive->id);
976 drive->id = NULL;
977 drive->dev_flags &= ~IDE_DFLAG_PRESENT;
975 continue; 978 continue;
976 } 979 }
977 980
981 j++;
982
978 ide_add_drive_to_hwgroup(drive); 983 ide_add_drive_to_hwgroup(drive);
979 } 984 }
980 mutex_unlock(&ide_cfg_mtx); 985 mutex_unlock(&ide_cfg_mtx);
986
987 return j;
981} 988}
982 989
983static ide_hwif_t *ide_ports[MAX_HWIFS]; 990static ide_hwif_t *ide_ports[MAX_HWIFS];
@@ -1663,10 +1670,13 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1663 continue; 1670 continue;
1664 } 1671 }
1665 1672
1666 j++;
1667
1668 if (hwif->present) 1673 if (hwif->present)
1669 ide_port_setup_devices(hwif); 1674 if (ide_port_setup_devices(hwif) == 0) {
1675 hwif->present = 0;
1676 continue;
1677 }
1678
1679 j++;
1670 1680
1671 ide_acpi_init(hwif); 1681 ide_acpi_init(hwif);
1672 1682