DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/ark: fix null dereference on allocation failure
@ 2026-06-03  5:21 Denis Sergeev
  2026-06-03  5:32 ` [PATCH v2] " Denis Sergeev
  2026-06-03 15:31 ` [PATCH] " Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Denis Sergeev @ 2026-06-03  5:21 UTC (permalink / raw)
  To: dev; +Cc: shepard.siegel, ed.czeck, john.miller, stable, sdl.dpdk,
	Denis Sergeev

rte_zmalloc_socket() can return NULL when memory is exhausted.
The result is passed directly to memcpy() without a NULL check,
leading to undefined behavior. Add a NULL check consistent with
the existing check for mac_addrs allocation in the same function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: bf73ee28f4 ("net/ark: support single function with multiple port")
Cc: stable@dpdk.org

Signed-off-by: Denis Sergeev <denserg.edu@gmail.com>
---
 drivers/net/ark/ark_ethdev.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ark/ark_ethdev.c b/drivers/net/ark/ark_ethdev.c
index 8b25ed948f..546a44704f 100644
--- a/drivers/net/ark/ark_ethdev.c
+++ b/drivers/net/ark/ark_ethdev.c
@@ -445,6 +445,12 @@ ark_dev_init(struct rte_eth_dev *dev)
 					   sizeof(struct ark_adapter),
 					   RTE_CACHE_LINE_SIZE,
 					   rte_socket_id());
+		if (eth_dev->data->dev_private == NULL) {
+			ARK_PMD_LOG(ERR,
+				    "Memory allocation for dev_private failed!"
+				    " Exiting.\n");
+			goto error;
+		}
 
 		memcpy(eth_dev->data->dev_private, ark,
 		       sizeof(struct ark_adapter));
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-03 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03  5:21 [PATCH] net/ark: fix null dereference on allocation failure Denis Sergeev
2026-06-03  5:32 ` [PATCH v2] " Denis Sergeev
2026-06-03 16:32   ` [PATCH v3] " Denis Sergeev
2026-06-03 15:31 ` [PATCH] " Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox