瀏覽代碼

[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>
Ravikiran G Thirumalai 20 年之前
父節點
當前提交
556e58febf
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      drivers/ide/ide-probe.c

+ 13 - 3
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)
 }
 }
 #endif /* MAX_HWIFS > 1 */
 #endif /* MAX_HWIFS > 1 */
 
 
+static inline int hwif_to_node(ide_hwif_t *hwif)
+{
+	if (hwif->pci_dev)
+		return pcibus_to_node(hwif->pci_dev->bus);
+	else
+		/* Add ways to determine the node of other busses here */
+		return -1;
+}
+
 /*
 /*
  * init request queue
  * init request queue
  */
  */
@@ -978,8 +987,7 @@ static int ide_init_queue(ide_drive_t *drive)
 	 *	do not.
 	 *	do not.
 	 */
 	 */
 
 
-	q = blk_init_queue_node(do_ide_request, &ide_lock,
-				pcibus_to_node(drive->hwif->pci_dev->bus));
+	q = blk_init_queue_node(do_ide_request, &ide_lock, hwif_to_node(hwif));
 	if (!q)
 	if (!q)
 		return 1;
 		return 1;
 
 
@@ -1048,6 +1056,8 @@ static int init_irq (ide_hwif_t *hwif)
 
 
 	BUG_ON(in_interrupt());
 	BUG_ON(in_interrupt());
 	BUG_ON(irqs_disabled());	
 	BUG_ON(irqs_disabled());	
+	BUG_ON(hwif == NULL);
+
 	down(&ide_cfg_sem);
 	down(&ide_cfg_sem);
 	hwif->hwgroup = NULL;
 	hwif->hwgroup = NULL;
 #if MAX_HWIFS > 1
 #if MAX_HWIFS > 1
@@ -1097,7 +1107,7 @@ static int init_irq (ide_hwif_t *hwif)
 		spin_unlock_irq(&ide_lock);
 		spin_unlock_irq(&ide_lock);
 	} else {
 	} else {
 		hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
 		hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
-			pcibus_to_node(hwif->drives[0].hwif->pci_dev->bus));
+					hwif_to_node(hwif->drives[0].hwif));
 		if (!hwgroup)
 		if (!hwgroup)
 	       		goto out_up;
 	       		goto out_up;