raw/cnxk_gpio: check pointer before use in self test
authorTomasz Duszynski <tduszynski@marvell.com>
Tue, 22 Feb 2022 08:28:17 +0000 (09:28 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 23 Feb 2022 17:28:10 +0000 (18:28 +0100)
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 <jerinj@marvell.com>
drivers/raw/cnxk_gpio/cnxk_gpio_selftest.c

index 7fccc48..acb65af 100644 (file)
@@ -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);