]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mpt2sas: fix the incorrect scsi_dma_map error checking
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Tue, 9 Mar 2010 02:09:50 +0000 (11:09 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 9 May 2011 22:55:39 +0000 (15:55 -0700)
commit bb789d01620e5d36081b22edb6fb71cf55ff043c upstream.

scsi_dma_map() returns -1 if an error occurred (zero means that the
command has no data). So the following current code can't catch an
error:

sges_left = scsi_dma_map(scmd);
if (!sges_left) {
sdev_printk(KERN_ERR, scmd->device, "pci_map_sg"
" failed: request for %d bytes!\n", scsi_bufflen(scmd));
return -ENOMEM;
}

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: "Kashyap Desai" <Kashyap.Desai@lsi.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/scsi/mpt2sas/mpt2sas_scsih.c

index 9e752067d78c6a6aaf422cb9a50c0067e9fb9877..cb972b6246c2959a2289f59f9fb2fe3ea950554a 100644 (file)
@@ -945,7 +945,7 @@ _scsih_build_scatter_gather(struct MPT2SAS_ADAPTER *ioc,
        u32 chain_offset;
        u32 chain_length;
        u32 chain_flags;
-       u32 sges_left;
+       int sges_left;
        u32 sges_in_segment;
        u32 sgl_flags;
        u32 sgl_flags_last_element;
@@ -966,7 +966,7 @@ _scsih_build_scatter_gather(struct MPT2SAS_ADAPTER *ioc,
 
        sg_scmd = scsi_sglist(scmd);
        sges_left = scsi_dma_map(scmd);
-       if (!sges_left) {
+       if (sges_left < 0) {
                sdev_printk(KERN_ERR, scmd->device, "pci_map_sg"
                " failed: request for %d bytes!\n", scsi_bufflen(scmd));
                return -ENOMEM;