Patch "s390/vfio-ap: fix memory leak in vfio_ap device driver" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    s390/vfio-ap: fix memory leak in vfio_ap device driver

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     s390-vfio-ap-fix-memory-leak-in-vfio_ap-device-drive.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit be66eeb996e120b448ba055f9058341cc01b9a21
Author: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>
Date:   Mon Mar 20 11:04:47 2023 -0400

    s390/vfio-ap: fix memory leak in vfio_ap device driver
    
    [ Upstream commit 8f8cf767589f2131ae5d40f3758429095c701c84 ]
    
    The device release callback function invoked to release the matrix device
    uses the dev_get_drvdata(device *dev) function to retrieve the
    pointer to the vfio_matrix_dev object in order to free its storage. The
    problem is, this object is not stored as drvdata with the device; since the
    kfree function will accept a NULL pointer, the memory for the
    vfio_matrix_dev object is never freed.
    
    Since the device being released is contained within the vfio_matrix_dev
    object, the container_of macro will be used to retrieve its pointer.
    
    Fixes: 1fde573413b5 ("s390: vfio-ap: base implementation of VFIO AP device driver")
    Signed-off-by: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>
    Reviewed-by: Harald Freudenberger <freude@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230320150447.34557-1-akrowiak@xxxxxxxxxxxxx
    Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
    Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c
index 997b524bdd2b5..a48c6938ae68f 100644
--- a/drivers/s390/crypto/vfio_ap_drv.c
+++ b/drivers/s390/crypto/vfio_ap_drv.c
@@ -54,8 +54,9 @@ static struct ap_driver vfio_ap_drv = {
 
 static void vfio_ap_matrix_dev_release(struct device *dev)
 {
-	struct ap_matrix_dev *matrix_dev = dev_get_drvdata(dev);
+	struct ap_matrix_dev *matrix_dev;
 
+	matrix_dev = container_of(dev, struct ap_matrix_dev, device);
 	kfree(matrix_dev);
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux