ide: fix kmalloc() failure handling in ide_driveid_update()

Previous thread: mn10300: remove <asm/ide.h> by Linux Kernel Mailing List on Thursday, March 26, 2009 - 12:25 pm. (1 message)

Next thread: edac: struct device - replace bus_id with dev_name(), dev_set_name() by Linux Kernel Mailing List on Thursday, March 26, 2009 - 12:25 pm. (1 message)
From: Linux Kernel Mailing List
Date: Thursday, March 26, 2009 - 12:25 pm

Gitweb:     http://git.kernel.org/linus/2f40c9b0b65b5635e2e13dfa068bd56fe7a8ff98
Commit:     2f40c9b0b65b5635e2e13dfa068bd56fe7a8ff98
Parent:     d45b70ab9bbf1a46ae52972d532f9e267b8d39d9
Author:     Bartlomiej Zolnierkiewicz &lt;bzolnier@gmail.com&gt;
AuthorDate: Tue Mar 24 23:22:54 2009 +0100
Committer:  Bartlomiej Zolnierkiewicz &lt;bzolnier@gmail.com&gt;
CommitDate: Tue Mar 24 23:22:54 2009 +0100

    ide: fix kmalloc() failure handling in ide_driveid_update()
    
    * Doing kmalloc() in the middle of command execution is not only ugly
      but leaves drive waiting to send data on kmalloc() failure.  Fix it.
    
    While at it:
    
    * Unify error code paths.
    
    * Fixup error message to be more useful and add missing KERN_ERR level.
    
    * Rename 'stat' variable to 's'.
    
    Signed-off-by: Bartlomiej Zolnierkiewicz &lt;bzolnier@gmail.com&gt;
---
 drivers/ide/ide-iops.c |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index e0cfa2d..a955483 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -293,7 +293,12 @@ int ide_driveid_update(ide_drive_t *drive)
 	const struct ide_tp_ops *tp_ops = hwif-&gt;tp_ops;
 	u16 *id;
 	unsigned long flags;
-	u8 stat;
+	int rc;
+	u8 uninitialized_var(s);
+
+	id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
+	if (id == NULL)
+		return 0;
 
 	/*
 	 * Re-read drive-&gt;id for possible DMA mode
@@ -306,25 +311,21 @@ int ide_driveid_update(ide_drive_t *drive)
 	tp_ops-&gt;exec_command(hwif, ATA_CMD_ID_ATA);
 
 	if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) {
-		SELECT_MASK(drive, 0);
-		return 0;
+		rc = 1;
+		goto out_err;
 	}
 
 	msleep(50);	/* wait for IRQ and ATA_DRQ */
-	stat = tp_ops-&gt;read_status(hwif);
 
-	if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) {
-		SELECT_MASK(drive, 0);
-		printk(&quot;%s: CHECK for good STATUS\n&quot;, drive-&gt;name);
-		return 0;
+	s = tp_ops-&gt;read_status(hwif);
+
+	if (!OK_STAT(s, ATA_DRQ, ...
Previous thread: mn10300: remove <asm/ide.h> by Linux Kernel Mailing List on Thursday, March 26, 2009 - 12:25 pm. (1 message)

Next thread: edac: struct device - replace bus_id with dev_name(), dev_set_name() by Linux Kernel Mailing List on Thursday, March 26, 2009 - 12:25 pm. (1 message)