Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=33480a0ede8dcc7e6483054279008f972bd56fd3
Commit:     33480a0ede8dcc7e6483054279008f972bd56fd3
Parent:     c10340aca270abb141154cd93dcf1be0b92143fc
Author:     Tejun Heo <[EMAIL PROTECTED]>
AuthorDate: Tue Dec 12 02:15:31 2006 +0900
Committer:  Jeff Garzik <[EMAIL PROTECTED]>
CommitDate: Sat Dec 16 10:13:22 2006 -0500

    [PATCH] libata: don't initialize sg in ata_exec_internal() if DMA_NONE 
(take #2)
    
    Calling sg_init_one() with NULL buf causes oops on certain
    configurations.  Don't initialize sg in ata_exec_internal() if
    DMA_NONE and make the function complain if @buf is NULL when dma_dir
    isn't DMA_NONE.  While at it, fix comment.
    
    The problem is discovered and initial patch was submitted by Arnd
    Bergmann.
    
    Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
    Cc: Arnd Bergmann <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/ata/libata-core.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 011c0a8..0d51d13 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1332,7 +1332,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
 }
 
 /**
- *     ata_exec_internal_sg - execute libata internal command
+ *     ata_exec_internal - execute libata internal command
  *     @dev: Device to which the command is sent
  *     @tf: Taskfile registers for the command and the result
  *     @cdb: CDB for packet command
@@ -1353,11 +1353,17 @@ unsigned ata_exec_internal(struct ata_device *dev,
                           struct ata_taskfile *tf, const u8 *cdb,
                           int dma_dir, void *buf, unsigned int buflen)
 {
-       struct scatterlist sg;
+       struct scatterlist *psg = NULL, sg;
+       unsigned int n_elem = 0;
 
-       sg_init_one(&sg, buf, buflen);
+       if (dma_dir != DMA_NONE) {
+               WARN_ON(!buf);
+               sg_init_one(&sg, buf, buflen);
+               psg = &sg;
+               n_elem++;
+       }
 
-       return ata_exec_internal_sg(dev, tf, cdb, dma_dir, &sg, 1);
+       return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem);
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to