net/ark: fix null dereference on allocation failure
PATCH 1/1 net/ark: fix null dereference on allocation failure
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.
--- drivers/net/ark/ark_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ark/ark_ethdev.c +6 -0
@@ -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 ));
Signature · 1 line
2.50.1
PATCH v2 1/1 net/ark: fix null dereference on allocation failure
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.
---
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(+)
drivers/net/ark/ark_ethdev.c +6 -0
@@ -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 ));
Signature · 1 line
2.50.1
PATCH v3 1/1 net/ark: fix null dereference on allocation failure
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.
---
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(+)
drivers/net/ark/ark_ethdev.c +4 -0
@@ -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 ));
Signature · 1 line
2.50.1
drivers/net/ark/ark_ethdev.c ark_dev_init(struct rte_eth_dev *dev) · line 451
Quoted 4 lines · On Wed, 3 Jun 2026 08:21:54 +0300 Denis Sergeev <[email protected]> wrote:
drivers/net/ark/ark_ethdev.c +4
-0+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.