aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRavikiran G Thirumalai <kiran@scalex86.org>2005-08-04 15:53:26 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-08-04 16:00:53 -0400
commit556e58febf90c8cb1da25669d0892bf5fd2ddac2 (patch)
tree427c4e5c414a2308107673d1b5197608426b652b /drivers
parentfd6f31c31825f62eb91f491e8316129e5ce81fc6 (diff)
[PATCH] ide: fix kmalloc_node breakage in ide driver
Patch fixes oops caused by ide interfaces not on pci. pcibus_to_node causes the kernel to crash otherwise. Patch also adds a BUG_ON to check if hwif is NULL. Signed-off-by: Christoph Lameter <christoph@lameter.com> Signed-off-by: Shai Fultheim <shai@scalex86.org> Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org> Cc: Andi Kleen <ak@muc.de> Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-probe.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 7df85af75371..94daf40ae323 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -960,6 +960,15 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
960} 960}
961#endif /* MAX_HWIFS > 1 */ 961#endif /* MAX_HWIFS > 1 */
962 962
963static inline int hwif_to_node(ide_hwif_t *hwif)
964{
965 if (hwif->pci_dev)
966 return pcibus_to_node(hwif->pci_dev->bus);
967 else
968 /* Add ways to determine the node of other busses here */
969 return -1;
970}
971
963/* 972/*
964 * init request queue 973 * init request queue
965 */ 974 */
@@ -978,8 +987,7 @@ static int ide_init_queue(ide_drive_t *drive)
978 * do not. 987 * do not.
979 */ 988 */
980 989
981 q = blk_init_queue_node(do_ide_request, &ide_lock, 990 q = blk_init_queue_node(do_ide_request, &ide_lock, hwif_to_node(hwif));
982 pcibus_to_node(drive->hwif->pci_dev->bus));
983 if (!q) 991 if (!q)
984 return 1; 992 return 1;
985 993
@@ -1048,6 +1056,8 @@ static int init_irq (ide_hwif_t *hwif)
1048 1056
1049 BUG_ON(in_interrupt()); 1057 BUG_ON(in_interrupt());
1050 BUG_ON(irqs_disabled()); 1058 BUG_ON(irqs_disabled());
1059 BUG_ON(hwif == NULL);
1060
1051 down(&ide_cfg_sem); 1061 down(&ide_cfg_sem);
1052 hwif->hwgroup = NULL; 1062 hwif->hwgroup = NULL;
1053#if MAX_HWIFS > 1 1063#if MAX_HWIFS > 1
@@ -1097,7 +1107,7 @@ static int init_irq (ide_hwif_t *hwif)
1097 spin_unlock_irq(&ide_lock); 1107 spin_unlock_irq(&ide_lock);
1098 } else { 1108 } else {
1099 hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL, 1109 hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
1100 pcibus_to_node(hwif->drives[0].hwif->pci_dev->bus)); 1110 hwif_to_node(hwif->drives[0].hwif));
1101 if (!hwgroup) 1111 if (!hwgroup)
1102 goto out_up; 1112 goto out_up;
1103 1113