[3/4] dmadev: fix potential null pointer access

Message ID 20240905064638.17980-4-haijie1@huawei.com (mailing list archive)
State New
Delegated to: David Marchand
Headers
Series clean code for dmadev and hns3 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jie Hai Sept. 5, 2024, 6:46 a.m. UTC
From: Chengwen Feng <fengchengwen@huawei.com>

When rte_dma_vchan_status(dev_id, vchan, NULL) is called, a null pointer
access is triggered.
This patch adds the null pointer checker.

Fixes: 5e0f85912754 ("dmadev: add channel status check for testing use")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/dmadev/rte_dmadev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 845727210fab..60c3d8ebf68e 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -741,7 +741,7 @@  rte_dma_vchan_status(int16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *
 {
 	struct rte_dma_dev *dev = &rte_dma_devices[dev_id];
 
-	if (!rte_dma_is_valid(dev_id))
+	if (!rte_dma_is_valid(dev_id) || status == NULL)
 		return -EINVAL;
 
 	if (vchan >= dev->data->dev_conf.nb_vchans) {