DPDK patches and discussions
 help / color / mirror / Atom feed
From: Mahipal Challa <mchalla@marvell.com>
To: <thomas@monjalon.net>, <dev@dpdk.org>
Cc: <jerinj@marvell.com>, <pathreya@marvell.com>,
	<snilla@marvell.com>, <venkatn@marvell.com>, <Gavin.Hu@arm.com>
Subject: [dpdk-dev] [dpdk-dev PATCH] raw/octeontx2_ep: fix coverity scan reported defects
Date: Mon, 27 Jan 2020 18:48:21 +0530	[thread overview]
Message-ID: <1580131101-16945-1-git-send-email-mchalla@marvell.com> (raw)

Defects reported by coverity scan are resolved.
Coverity issue: CID 353611 - Error handling.
Coverity issue: CID 353622 - Error handling.
Coverity issue: CID 353632 - NULL pointer dereference.

Signed-off-by: Mahipal Challa <mchalla@marvell.com>
---
 drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c b/drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c
index 1ba27c9..9f1e5ed 100644
--- a/drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c
+++ b/drivers/raw/octeontx2_ep/otx2_ep_enqdeq.c
@@ -257,8 +257,8 @@
 	void *buf;
 
 	for (idx = 0; idx < droq->nb_desc; idx++) {
-		rte_mempool_get(sdpvf->enqdeq_mpool, &buf);
-		if (buf == NULL) {
+		if (rte_mempool_get(sdpvf->enqdeq_mpool, &buf) ||
+		    (buf == NULL)) {
 			otx2_err("OQ buffer alloc failed");
 			droq->stats.rx_alloc_failure++;
 			/* sdp_droq_destroy_ring_buffers(droq);*/
@@ -662,11 +662,11 @@
 		if (droq->recv_buf_list[droq->refill_idx].buffer != NULL)
 			break;
 
-		rte_mempool_get(sdpvf->enqdeq_mpool, &buf);
-		/* If a buffer could not be allocated, no point in
-		 * continuing
-		 */
-		if (buf == NULL) {
+		if (rte_mempool_get(sdpvf->enqdeq_mpool, &buf) ||
+		    (buf == NULL)) {
+			/* If a buffer could not be allocated, no point in
+			 * continuing
+			 */
 			droq->stats.rx_alloc_failure++;
 			break;
 		}
@@ -780,7 +780,7 @@
 	droq = sdpvf->droq[q_no];
 	if (!droq) {
 		otx2_err("Invalid droq[%d]", q_no);
-		goto deq_fail;
+		goto droq_err;
 	}
 
 	/* Grab the lock */
@@ -840,5 +840,7 @@
 
 deq_fail:
 	rte_spinlock_unlock(&droq->lock);
+
+droq_err:
 	return SDP_OQ_RECV_FAILED;
 }
-- 
1.8.3.1


             reply	other threads:[~2020-01-27 13:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 13:18 Mahipal Challa [this message]
2020-02-06 15:51 ` Thomas Monjalon

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=1580131101-16945-1-git-send-email-mchalla@marvell.com \
    --to=mchalla@marvell.com \
    --cc=Gavin.Hu@arm.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=pathreya@marvell.com \
    --cc=snilla@marvell.com \
    --cc=thomas@monjalon.net \
    --cc=venkatn@marvell.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).