* [PATCH] lib: Check for the NULL pointer after calling malloc
@ 2022-07-07 9:23 835703180
2022-10-10 15:46 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: 835703180 @ 2022-07-07 9:23 UTC (permalink / raw)
To: pbhagavatula; +Cc: dev, Shiqi Liu
From: Shiqi Liu <835703180@qq.com>
As the possible failure of the malloc(), 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 ("lib/node: add ethdev control")
Signed-off-by: Shiqi Liu <835703180@qq.com>
---
lib/node/ethdev_ctrl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/node/ethdev_ctrl.c b/lib/node/ethdev_ctrl.c
index 5294607619..eef0785c21 100644
--- a/lib/node/ethdev_ctrl.c
+++ b/lib/node/ethdev_ctrl.c
@@ -75,6 +75,9 @@ rte_node_eth_config(struct rte_node_ethdev_config *conf, uint16_t nb_confs,
/* Add it to list of ethdev rx nodes for lookup */
elem = malloc(sizeof(ethdev_rx_node_elem_t));
+ if (elem == NULL) {
+ return -ENOMEM;
+ }
memset(elem, 0, sizeof(ethdev_rx_node_elem_t));
elem->ctx.port_id = port_id;
elem->ctx.queue_id = j;
--
2.35.1.windows.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-10 15:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 9:23 [PATCH] lib: Check for the NULL pointer after calling malloc 835703180
2022-10-10 15:46 ` Thomas Monjalon
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).