Commit cf3968c5 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] ide: remove kmalloc() from ide_unregister()

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: default avatarJorn Engel <joern@wh.fh-wedel.de>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b6877e8c
...@@ -763,18 +763,13 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif) ...@@ -763,18 +763,13 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
void ide_unregister(unsigned int index) void ide_unregister(unsigned int index)
{ {
ide_drive_t *drive; 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; ide_hwgroup_t *hwgroup;
int irq_count = 0, unit, i; int irq_count = 0, unit, i;
BUG_ON(index >= MAX_HWIFS); 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(in_interrupt());
BUG_ON(irqs_disabled()); BUG_ON(irqs_disabled());
down(&ide_cfg_sem); down(&ide_cfg_sem);
...@@ -921,19 +916,17 @@ void ide_unregister(unsigned int index) ...@@ -921,19 +916,17 @@ void ide_unregister(unsigned int index)
} }
/* copy original settings */ /* copy original settings */
*tmp_hwif = *hwif; tmp_hwif = *hwif;
/* restore hwif data to pristine status */ /* restore hwif data to pristine status */
init_hwif_data(hwif, index); init_hwif_data(hwif, index);
init_hwif_default(hwif, index); init_hwif_default(hwif, index);
ide_hwif_restore(hwif, tmp_hwif); ide_hwif_restore(hwif, &tmp_hwif);
abort: abort:
spin_unlock_irq(&ide_lock); spin_unlock_irq(&ide_lock);
up(&ide_cfg_sem); up(&ide_cfg_sem);
kfree(tmp_hwif);
} }
EXPORT_SYMBOL(ide_unregister); EXPORT_SYMBOL(ide_unregister);
......
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