* [PATCH] scsi: cxgbi: add null check before pointer dereference
@ 2017-05-22 16:03 Gustavo A. R. Silva
0 siblings, 0 replies; only message in thread
From: Gustavo A. R. Silva @ 2017-05-22 16:03 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen
Cc: linux-scsi, linux-kernel, Gustavo A. R. Silva
Add null check before dereferencing pointer _sg_ inside sg_next()
Addresses-Coverity-ID: 1364845
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-22 16:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-22 16:03 [PATCH] scsi: cxgbi: add null check before pointer dereference Gustavo A. R. Silva
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.