summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorZijun Hu <quic_zijuhu@quicinc.com>2024-07-02 17:51:51 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-07-04 13:34:50 +0300
commitbd50a974097bb82d52a458bd3ee39fb723129a0c (patch)
treeff3ae3b73b4ba1ee398a968a373d64d47faf3960 /drivers/base
parentc884e3249f753dcef7a2b2023541ac1dc46b318e (diff)
downloadlinux-bd50a974097bb82d52a458bd3ee39fb723129a0c.tar.xz
devres: Fix memory leakage caused by driver API devm_free_percpu()
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@vger.kernel.org Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Link: https://lore.kernel.org/r/1719931914-19035-3-git-send-email-quic_zijuhu@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/devres.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index ff2247eec43c..8d709dbd4e0c 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -1225,7 +1225,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);