net/dpaa2: fix null pointer dereference

Message ID tencent_093A79DF3423D6227E31B03CE6A71E113B08@qq.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/dpaa2: fix null pointer dereference |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Weiguo Li Jan. 25, 2022, 2:23 p.m. UTC
  Check for memory allocation failure is added to avoid null
pointer dereference.

Fixes: 4690a6114ff6 ("net/dpaa2: enable error queues optionally")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Ferruh Yigit Jan. 28, 2022, 3:12 p.m. UTC | #1
On 1/25/2022 2:23 PM, Weiguo Li wrote:
> Check for memory allocation failure is added to avoid null
> pointer dereference.
> 
> Fixes: 4690a6114ff6 ("net/dpaa2: enable error queues optionally")
> 
> Signed-off-by: Weiguo Li <liwg06@foxmail.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 09105f049e..379daec5f4 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -399,6 +399,8 @@  dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	if (dpaa2_enable_err_queue) {
 		priv->rx_err_vq = rte_zmalloc("dpni_rx_err",
 			sizeof(struct dpaa2_queue), 0);
+		if (!priv->rx_err_vq)
+			goto fail;
 
 		dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq;
 		dpaa2_q->q_storage = rte_malloc("err_dq_storage",