[PATCH] scsi: cxgbi: add null check before pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add null check before dereferencing pointer _sg_ inside sg_next()

Addresses-Coverity-ID: 1364845
Signed-off-by: Gustavo A. R. Silva <garsilva@xxxxxxxxxxxxxx>
---
 drivers/scsi/cxgbi/libcxgbi.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index bd7d39e..6119ddf 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -1256,15 +1256,18 @@ void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *ppod,
 		*sg_off = offset;
 	}
 
-	if (offset == len) {
-		offset = 0;
-		sg = sg_next(sg);
-		if (sg) {
-			addr = sg_dma_address(sg);
-			len = sg_dma_len(sg);
+	if (sg) {
+		if (offset == len) {
+			offset = 0;
+			sg = sg_next(sg);
+			if (sg) {
+				addr = sg_dma_address(sg);
+				len = sg_dma_len(sg);
+			}
 		}
-	}
-	ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL;
+		ppod->addr[i] = cpu_to_be64(addr + offset);
+	} else
+		ppod->addr[i] = 0ULL;
 }
 EXPORT_SYMBOL_GPL(cxgbi_ddp_set_one_ppod);
 
-- 
2.5.0




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux