DPDK patches and discussions
 help / color / mirror / Atom feed
From: 835703180@qq.com
To: harry.van.haaren@intel.com
Cc: dev@dpdk.org, Shiqi Liu <835703180@qq.com>
Subject: [PATCH] examples/eventdev: Check for the NULL pointer after calling rte_zmalloc
Date: Wed,  6 Jul 2022 15:23:15 +0800	[thread overview]
Message-ID: <tencent_E049786768575AD04105555B3D3730A17B0A@qq.com> (raw)

From: Shiqi Liu <835703180@qq.com>

As the possible failure of the rte_zmalloc(), the not_checked and
checked could be NULL pointer.
Therefore, it should be better to check it in order to avoid
the dereference of the NULL pointer.

Fixes: fa8054c8c88 ("examples/eventdev: add thread safe Tx worker pipeline")
Signed-off-by: Shiqi Liu <835703180@qq.com>
---
 examples/eventdev_pipeline/pipeline_worker_tx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/examples/eventdev_pipeline/pipeline_worker_tx.c b/examples/eventdev_pipeline/pipeline_worker_tx.c
index a82e064c1c..6ea676c516 100644
--- a/examples/eventdev_pipeline/pipeline_worker_tx.c
+++ b/examples/eventdev_pipeline/pipeline_worker_tx.c
@@ -764,7 +764,9 @@ init_adapters(uint16_t nb_ports)
 
 	ret = rte_event_dev_info_get(evdev_id, &dev_info);
 	adptr_services = rte_zmalloc(NULL, sizeof(struct rx_adptr_services), 0);
-
+	if (adptr_services == NULL) {
+		return -ENOMEM;
+	}
 	struct rte_event_port_conf adptr_p_conf = {
 		.dequeue_depth = cdata.worker_cq_depth,
 		.enqueue_depth = 64,
-- 
2.35.1.windows.2


             reply	other threads:[~2022-07-06  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06  7:23 835703180 [this message]
2022-09-13 12:17 ` Jerin Jacob

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=tencent_E049786768575AD04105555B3D3730A17B0A@qq.com \
    --to=835703180@qq.com \
    --cc=dev@dpdk.org \
    --cc=harry.van.haaren@intel.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).