[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20170522160328.GA15668@embeddedgus>
Date: Mon, 22 May 2017 11:03:28 -0500
From: "Gustavo A. R. Silva" <garsilva@...eddedor.com>
To: "James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
"Gustavo A. R. Silva" <garsilva@...eddedor.com>
Subject: [PATCH] scsi: cxgbi: add null check before pointer dereference
Add null check before dereferencing pointer _sg_ inside sg_next()
Addresses-Coverity-ID: 1364845
Signed-off-by: Gustavo A. R. Silva <garsilva@...eddedor.com>
---
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
Powered by blists - more mailing lists