Patch "drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()" has been added to the 6.0-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/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()

to the 6.0-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-nouveau-nouveau_bo-fix-potential-memory-leak-in-.patch
and it can be found in the queue-6.0 subdirectory.

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



commit cb3940d53ef05030063d94e6d33378da31bb9d81
Author: Jianglei Nie <niejianglei2021@xxxxxxx>
Date:   Tue Jul 5 17:43:06 2022 +0800

    drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()
    
    [ Upstream commit 6dc548745d5b5102e3c53dc5097296ac270b6c69 ]
    
    nouveau_bo_alloc() allocates a memory chunk for "nvbo" with kzalloc().
    When some error occurs, "nvbo" should be released. But when
    WARN_ON(pi < 0)) equals true, the function return ERR_PTR without
    releasing the "nvbo", which will lead to a memory leak.
    
    We should release the "nvbo" with kfree() if WARN_ON(pi < 0)) equals true.
    
    Signed-off-by: Jianglei Nie <niejianglei2021@xxxxxxx>
    Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
    Reviewed-by: Lyude Paul <lyude@xxxxxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220705094306.2244103-1-niejianglei2021@xxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index e29175e4b44c..07a327ad5e2a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -281,8 +281,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 domain,
 			break;
 	}
 
-	if (WARN_ON(pi < 0))
+	if (WARN_ON(pi < 0)) {
+		kfree(nvbo);
 		return ERR_PTR(-EINVAL);
+	}
 
 	/* Disable compression if suitable settings couldn't be found. */
 	if (nvbo->comp && !vmm->page[pi].comp) {



[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