common/cnxk: fix null pointer dereference
Checks
Commit Message
Fix null pointer dereference reported in coverity scan.
Coverity issue: 372065
Fixes: 665b6a7400b ("common/cnxk: add NPC helper API")
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
drivers/common/cnxk/roc_npc_utils.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Sun, Apr 24, 2022 at 9:47 PM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> Fix null pointer dereference reported in coverity scan.
>
> Coverity issue: 372065
Cc: stable@dpdk.org
> Fixes: 665b6a7400b ("common/cnxk: add NPC helper API")
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Applied to dpdk-next-net-mrvl/for-next-net. Thanks
> ---
> drivers/common/cnxk/roc_npc_utils.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/common/cnxk/roc_npc_utils.c b/drivers/common/cnxk/roc_npc_utils.c
> index f9768ea3cf..dadd8826cb 100644
> --- a/drivers/common/cnxk/roc_npc_utils.c
> +++ b/drivers/common/cnxk/roc_npc_utils.c
> @@ -145,6 +145,9 @@ npc_parse_item_basic(const struct roc_npc_item_info *item,
> info->mask = item->mask;
> }
>
> + if (info->mask == NULL)
> + return NPC_ERR_INVALID_MASK;
> +
> /* mask specified must be subset of hw supported mask
> * mask | hw_mask == hw_mask
> */
> --
> 2.25.1
>
@@ -145,6 +145,9 @@ npc_parse_item_basic(const struct roc_npc_item_info *item,
info->mask = item->mask;
}
+ if (info->mask == NULL)
+ return NPC_ERR_INVALID_MASK;
+
/* mask specified must be subset of hw supported mask
* mask | hw_mask == hw_mask
*/