drm/nouveau: Fix memory leak in nouveau_bo_alloc
Subsystems (4)
PATCH 1/1 drm/nouveau: Fix memory leak in nouveau_bo_alloc
In the implementation of nouveau_bo_alloc() if it fails to determine the target page size via pi, then the allocated memory for nvbo should be released.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -1
@@ -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) {
Signature · 1 line
2.17.1
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 flags, · line 285
Quoted 13 lines
+++
b/drivers/gpu/drm/nouveau/nouveau_bo.cdrivers/gpu/drm/nouveau/nouveau_bo.c +3
-1@@ -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) {
This addition looks correct.
But I would prefer to move such exception handling code to the end of this function implementation so that duplicate source code will be reduced.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=7d194c2100ad2a6dded545887d02754948ca5241#n450
Regards,
Markus
Quoted 7 lines · Navid Emamdoost
In the implementation of
nouveau_bo_alloc()if it fails to determine the target page size via pi, then the allocated memory for nvbo should be released.Fixes 019cbd4a4feb ("drm/nouveau: Initialize GEM object before TTM object")Signed-off-by Navid Emamdoost <[email protected]>
Would you please review this patch?
Thanks,
Navid.
Quoted 23 lines
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/nouveau/nouveau_bo.c +3
-2@@ -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) { --2.17.1
Signature · 1 line
Navid.
ping...
Quoted 44 lines · Navid Emamdoost
Quoted 7 lines · Navid Emamdoost
In the implementation of
nouveau_bo_alloc()if it fails to determine the target page size via pi, then the allocated memory for nvbo should be released.Fixes 019cbd4a4feb ("drm/nouveau: Initialize GEM object before TTM object")Signed-off-by Navid Emamdoost <[email protected]>Would you please review this patch?
Thanks,
Navid.Quoted 21 lines
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/nouveau/nouveau_bo.c +3
-2@@ -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) { --Quoted 2 lines
2.17.1
--
Navid.
Signature · 1 line
Navid.
ping ...
Quoted 54 lines · Navid Emamdoost
ping...
Quoted 35 lines · Navid Emamdoost
Quoted 7 lines · Navid Emamdoost
In the implementation of
nouveau_bo_alloc()if it fails to determine the target page size via pi, then the allocated memory for nvbo should be released.Fixes 019cbd4a4feb ("drm/nouveau: Initialize GEM object before TTM object")Signed-off-by Navid Emamdoost <[email protected]>Would you please review this patch?
Thanks,
Navid.Quoted 18 lines
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/nouveau/nouveau_bo.c +3
-1@@ -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 ); + }Quoted 9 lines
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +0
-1/* Disable compression if suitable settings couldn't be found. */ if (nvbo->comp && !vmm->page[pi].comp) { --2.17.1
--
Navid.--
Navid.
Signature · 1 line
Navid.