DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tduszynski@marvell.com>
To: <dev@dpdk.org>, Jakub Palider <jpalider@marvell.com>,
	Tomasz Duszynski <tduszynski@marvell.com>
Cc: <thomas@monjalon.net>, <jerinj@marvell.com>
Subject: [PATCH 2/2] raw/cnxk_gpio: check pointer before using it
Date: Tue, 22 Feb 2022 09:28:17 +0100	[thread overview]
Message-ID: <20220222082817.1057701-3-tduszynski@marvell.com> (raw)
In-Reply-To: <20220222082817.1057701-1-tduszynski@marvell.com>

Even though nonexistent cnxk_gpio is unlikely at this point
it's a good practice to check pointers before using them.

Fixes: 0e6557b448fa ("raw/cnxk_gpio: add self test")
Coverity issue: 376502

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
Reviewed-by: Jerin Jacob Kollanukkaran <jerinj@marvell.com>
---
 drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
index 7fccc48f30..acb65afa65 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c
@@ -311,6 +311,8 @@ cnxk_gpio_selftest(uint16_t dev_id)
 	int ret, ret2;
 
 	rawdev = rte_rawdev_pmd_get_named_dev("cnxk_gpio");
+	if (!rawdev)
+		return -ENODEV;
 	gpiochip = rawdev->dev_private;
 
 	queues = rte_rawdev_queue_count(dev_id);
-- 
2.25.1


  parent reply	other threads:[~2022-02-22  8:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22  8:28 [PATCH 0/2] raw/cnxk_gpio: fix issues discovered by coverity Tomasz Duszynski
2022-02-22  8:28 ` [PATCH 1/2] raw/cnxk_gpio: fix resource leak Tomasz Duszynski
2022-02-22  8:28 ` Tomasz Duszynski [this message]
2022-02-23 17:29 ` [PATCH 0/2] raw/cnxk_gpio: fix issues discovered by coverity 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=20220222082817.1057701-3-tduszynski@marvell.com \
    --to=tduszynski@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=jpalider@marvell.com \
    --cc=thomas@monjalon.net \
    /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).