From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: [PATCH] scsi: cxgbi: add null check before pointer dereference
Date: Mon, 22 May 2017 11:03:28 -0500 [thread overview]
Message-ID: <20170522160328.GA15668@embeddedgus> (raw)
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
reply other threads:[~2017-05-22 16:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170522160328.GA15668@embeddedgus \
--to=garsilva@embeddedor.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.