crypto/dpaa_sec: repair memory allocations
This patch repairs 2 memory allocations issues: 1) possible leak of memory In cryptodev_dpaa_sec_probe() function in case of portal initialization failure, function exited without cleanup. The patch redirects flow to out label, which provides proper cleanup in case of error: freeing cryptodevice private data and releasing cryptodevice. 2) double free of cryptodev private data The function dpaa_sec_dev_init() in case of failure called dpaa_sec_uninit() which freed both private data and security context. However one layer above in cryptodev_dpaa_sec_probe() function, the private data were freed one more time. The patch limits cleanup of the dpaa_sec_dev_init() function to freeing only the security context. Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
This commit is contained in:
parent
6290de2c3f
commit
2eaf352d3d
@ -3410,7 +3410,7 @@ dpaa_sec_dev_init(struct rte_cryptodev *cryptodev)
|
||||
init_error:
|
||||
DPAA_SEC_ERR("driver %s: create failed\n", cryptodev->data->name);
|
||||
|
||||
dpaa_sec_uninit(cryptodev);
|
||||
rte_free(cryptodev->security_ctx);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
@ -3467,7 +3467,7 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
|
||||
retval = rte_dpaa_portal_init((void *)1);
|
||||
if (retval) {
|
||||
DPAA_SEC_ERR("Unable to initialize portal");
|
||||
return retval;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3476,13 +3476,15 @@ cryptodev_dpaa_sec_probe(struct rte_dpaa_driver *dpaa_drv __rte_unused,
|
||||
if (retval == 0)
|
||||
return 0;
|
||||
|
||||
retval = -ENXIO;
|
||||
out:
|
||||
/* In case of error, cleanup is done */
|
||||
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
|
||||
rte_free(cryptodev->data->dev_private);
|
||||
|
||||
rte_cryptodev_pmd_release_device(cryptodev);
|
||||
|
||||
return -ENXIO;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user