Re: [PATCH] s390/vfio-ap: Fix module unload memory leak of matrix_dev

From: Tony Krowiak
Date: Fri Jun 18 2021 - 11:33:02 EST


Reviewed-by: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>

On 6/18/21 9:35 AM, Jason J. Herne wrote:
vfio_ap_matrix_dev_release is shadowing the global matrix_dev with driver
data that never gets set. So when release is called we end up not freeing
matrix_dev. The fix is to remove the shadow variable and just free the
global.

Signed-off-by: Jason J. Herne <jjherne@xxxxxxxxxxxxx>
---
drivers/s390/crypto/vfio_ap_drv.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c
index 7dc72cb718b0..6d3eea838e18 100644
--- a/drivers/s390/crypto/vfio_ap_drv.c
+++ b/drivers/s390/crypto/vfio_ap_drv.c
@@ -82,8 +82,6 @@ static void vfio_ap_queue_dev_remove(struct ap_device *apdev)
static void vfio_ap_matrix_dev_release(struct device *dev)
{
- struct ap_matrix_dev *matrix_dev = dev_get_drvdata(dev);
-
kfree(matrix_dev);
}