|SUCCESS| net/ark: fix null dereference on allocation failure
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Jun 3 18:40:20 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164871
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-03
Reviewing patch: net/ark: fix null dereference on allocation failure
commit bf73ee28f4 ("net/ark: support single function with multiple port")
Author: Denis Sergeev <denserg.edu at gmail.com>
net/ark: fix null dereference on allocation failure
This patch adds a NULL check after rte_zmalloc_socket() to prevent
undefined behavior when memory allocation fails.
> 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");
The coding style guide prohibits unnecessary exclamation marks and
discourages overly dramatic error messages. Can this be changed to:
"Failed to allocate memory for dev_private\n"
Also, does the newline character need to be on a separate string literal?
The ARK_PMD_LOG macro likely expands to include its own newline handling,
making the trailing "\n" within the format string potentially redundant
or creating double newlines.
> + goto error;
> + }
>
> memcpy(eth_dev->data->dev_private, ark,
> sizeof(struct ark_adapter));
Does this error path properly clean up all previously allocated resources
before reaching the 'error' label? Looking at the function context, if
this allocation fails after rte_eth_dev_probing_finish() was called or
other resources were allocated, are those properly released by the error
label handler?
More information about the test-report
mailing list