Patch "drm/drv: Fix potential memory leak in drm_dev_init()" has been added to the 5.15-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

    drm/drv: Fix potential memory leak in drm_dev_init()

to the 5.15-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:
     drm-drv-fix-potential-memory-leak-in-drm_dev_init.patch
and it can be found in the queue-5.15 subdirectory.

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



commit f97ce822f3fe633a29171cdfa06cbe37dcc58f96
Author: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
Date:   Tue Nov 1 15:07:15 2022 +0800

    drm/drv: Fix potential memory leak in drm_dev_init()
    
    [ Upstream commit ff963634f7b2e0dc011349abb3fb81a0d074f443 ]
    
    drm_dev_init() will add drm_dev_init_release() as a callback. When
    drmm_add_action() failed, the release function won't be added. As the
    result, the ref cnt added by device_get() in drm_dev_init() won't be put
    by drm_dev_init_release(), which leads to the memleak. Use
    drmm_add_action_or_reset() instead of drmm_add_action() to prevent
    memleak.
    
    unreferenced object 0xffff88810bc0c800 (size 2048):
      comm "modprobe", pid 8322, jiffies 4305809845 (age 15.292s)
      hex dump (first 32 bytes):
        e8 cc c0 0b 81 88 ff ff ff ff ff ff 00 00 00 00  ................
        20 24 3c 0c 81 88 ff ff 18 c8 c0 0b 81 88 ff ff   $<.............
      backtrace:
        [<000000007251f72d>] __kmalloc+0x4b/0x1c0
        [<0000000045f21f26>] platform_device_alloc+0x2d/0xe0
        [<000000004452a479>] platform_device_register_full+0x24/0x1c0
        [<0000000089f4ea61>] 0xffffffffa0736051
        [<00000000235b2441>] do_one_initcall+0x7a/0x380
        [<0000000001a4a177>] do_init_module+0x5c/0x230
        [<000000002bf8a8e2>] load_module+0x227d/0x2420
        [<00000000637d6d0a>] __do_sys_finit_module+0xd5/0x140
        [<00000000c99fc324>] do_syscall_64+0x3f/0x90
        [<000000004d85aa77>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Fixes: 2cbf7fc6718b ("drm: Use drmm_ for drm_dev_init cleanup")
    Signed-off-by: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
    Reviewed-by: Lyude Paul <lyude@xxxxxxxxxx>
    Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20221101070716.9189-2-shangxiaojing@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index b3a1636d1b98..6f1791613757 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -614,7 +614,7 @@ static int drm_dev_init(struct drm_device *dev,
 	mutex_init(&dev->clientlist_mutex);
 	mutex_init(&dev->master_mutex);
 
-	ret = drmm_add_action(dev, drm_dev_init_release, NULL);
+	ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL);
 	if (ret)
 		return ret;
 



[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