mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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 <[email protected]> Signed-off-by: Lyude Paul <[email protected]> Reviewed-by: Lyude Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
61fd56b0a1
commit
1d0803b153
1 changed files with 3 additions and 1 deletions
|
|
@ -276,8 +276,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 flags,
|
|||
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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue