Patch "devres: Fix memory leakage caused by driver API devm_free_percpu()" has been added to the 5.10-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

    devres: Fix memory leakage caused by driver API devm_free_percpu()

to the 5.10-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:
     devres-fix-memory-leakage-caused-by-driver-api-devm_.patch
and it can be found in the queue-5.10 subdirectory.

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



commit f719c758e33b8380fbbfc31ec202e5a74f80d568
Author: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
Date:   Tue Jul 2 22:51:51 2024 +0800

    devres: Fix memory leakage caused by driver API devm_free_percpu()
    
    [ Upstream commit bd50a974097bb82d52a458bd3ee39fb723129a0c ]
    
    It will cause memory leakage when use driver API devm_free_percpu()
    to free memory allocated by devm_alloc_percpu(), fixed by using
    devres_release() instead of devres_destroy() within devm_free_percpu().
    
    Fixes: ff86aae3b411 ("devres: add devm_alloc_percpu()")
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Zijun Hu <quic_zijuhu@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/1719931914-19035-3-git-send-email-quic_zijuhu@xxxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index a1508eeb8ebd1..8a74008c13c44 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -1230,7 +1230,11 @@ EXPORT_SYMBOL_GPL(__devm_alloc_percpu);
  */
 void devm_free_percpu(struct device *dev, void __percpu *pdata)
 {
-	WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match,
+	/*
+	 * Use devres_release() to prevent memory leakage as
+	 * devm_free_pages() does.
+	 */
+	WARN_ON(devres_release(dev, devm_percpu_release, devm_percpu_match,
 			       (__force void *)pdata));
 }
 EXPORT_SYMBOL_GPL(devm_free_percpu);




[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