dma/idxd: check DSA device allocation

As the possible failure of the malloc(), the not_checked and
checked could be NULL pointer.
Therefore, it should be better to check it in order to avoid
the dereference of the NULL pointer.

Fixes: b7aaf417f9 ("raw/ioat: add bus driver for device scanning automatically")
Cc: stable@dpdk.org

Signed-off-by: Shiqi Liu <835703180@qq.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
Shiqi Liu 2022-07-06 14:55:48 +08:00 committed by Thomas Monjalon
parent d914c01036
commit 390c482276

View File

@ -335,6 +335,10 @@ dsa_scan(void)
IDXD_PMD_DEBUG("%s(): found %s/%s", __func__, path, wq->d_name);
dev = malloc(sizeof(*dev));
if (dev == NULL) {
closedir(dev_dir);
return -ENOMEM;
}
if (dsa_addr_parse(wq->d_name, &dev->addr) < 0) {
IDXD_PMD_ERR("Error parsing WQ name: %s", wq->d_name);
free(dev);