]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ide: remove kmalloc() from ide_unregister()
authorBartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>
Fri, 10 Sep 2004 04:03:08 +0000 (21:03 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 10 Sep 2004 04:03:08 +0000 (21:03 -0700)
tmp_hwif should not be kmalloc()ed in ide_unregister().
If the kmalloc fails, there is no possible error recovery.
This patch makes tmp_hwif static, protected by ide_cfg_sem.

Signed-off-by: Jorn Engel <joern@wh.fh-wedel.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/ide/ide.c

index 190b2e28f54ecdfbca6f36c109572490784759f7..c57bd4cc9e20fd9abbc611fb01022458305ba2e3 100644 (file)
@@ -763,18 +763,13 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
 void ide_unregister(unsigned int index)
 {
        ide_drive_t *drive;
-       ide_hwif_t *hwif, *g, *tmp_hwif;
+       ide_hwif_t *hwif, *g;
+       static ide_hwif_t tmp_hwif; /* protected by ide_cfg_sem */
        ide_hwgroup_t *hwgroup;
        int irq_count = 0, unit, i;
 
        BUG_ON(index >= MAX_HWIFS);
 
-       tmp_hwif = kmalloc(sizeof(*tmp_hwif), GFP_KERNEL|__GFP_NOFAIL);
-       if (!tmp_hwif) {
-               printk(KERN_ERR "%s: unable to allocate memory\n", __FUNCTION__);
-               return;
-       }
-
        BUG_ON(in_interrupt());
        BUG_ON(irqs_disabled());
        down(&ide_cfg_sem);
@@ -921,19 +916,17 @@ void ide_unregister(unsigned int index)
        }
 
        /* copy original settings */
-       *tmp_hwif = *hwif;
+       tmp_hwif = *hwif;
 
        /* restore hwif data to pristine status */
        init_hwif_data(hwif, index);
        init_hwif_default(hwif, index);
 
-       ide_hwif_restore(hwif, tmp_hwif);
+       ide_hwif_restore(hwif, &tmp_hwif);
 
 abort:
        spin_unlock_irq(&ide_lock);
        up(&ide_cfg_sem);
-
-       kfree(tmp_hwif);
 }
 
 EXPORT_SYMBOL(ide_unregister);