* [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
* [PATCH v2] net/ark: fix null dereference on allocation failure
2026-06-03 5:21 [PATCH] net/ark: fix null dereference on allocation failure Denis Sergeev
@ 2026-06-03 5:32 ` Denis Sergeev
2026-06-03 16:32 ` [PATCH v3] " Denis Sergeev
2026-06-03 15:31 ` [PATCH] " Stephen Hemminger
1 sibling, 1 reply; 4+ messages in thread
From: Denis Sergeev @ 2026-06-03 5:32 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: bf73ee28f47b ("net/ark: support single function with multiple port")
Cc: stable@dpdk.org
Signed-off-by: Denis Sergeev <denserg.edu@gmail.com>
---
v2:
* Fix Fixes: tag to use 12-char sha1 (checkpatch BAD_FIXES_TAG)
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
* Re: [PATCH] net/ark: fix null dereference on allocation failure
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 15:31 ` Stephen Hemminger
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2026-06-03 15:31 UTC (permalink / raw)
To: Denis Sergeev
Cc: dev, shepard.siegel, ed.czeck, john.miller, stable, sdl.dpdk
On Wed, 3 Jun 2026 08:21:54 +0300
Denis Sergeev <denserg.edu@gmail.com> wrote:
> + if (eth_dev->data->dev_private == NULL) {
> + ARK_PMD_LOG(ERR,
> + "Memory allocation for dev_private failed!"
> + " Exiting.\n");
Do not split error messages across lines. And no need for ! and the Exiting part.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3] net/ark: fix null dereference on allocation failure
2026-06-03 5:32 ` [PATCH v2] " Denis Sergeev
@ 2026-06-03 16:32 ` Denis Sergeev
0 siblings, 0 replies; 4+ messages in thread
From: Denis Sergeev @ 2026-06-03 16:32 UTC (permalink / raw)
To: dev; +Cc: shepard.siegel, ed.czeck, john.miller, stephen, stable,
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: bf73ee28f47b ("net/ark: support single function with multiple port")
Cc: stable@dpdk.org
Signed-off-by: Denis Sergeev <denserg.edu@gmail.com>
---
v3:
* Use a single-line error message without "!" and "Exiting"
v2:
* Fix Fixes: tag to use 12-char sha1 (checkpatch BAD_FIXES_TAG)
drivers/net/ark/ark_ethdev.c | 4 ++++
1 file changed, 4 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,10 @@ 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\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