linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] drm/nouveau: add the missed kfree() for nouveau_bo_alloc()
@ 2020-07-15 18:12 Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2020-07-15 18:12 UTC (permalink / raw)
  To: Jing Xiangfeng, dri-devel, nouveau
  Cc: kernel-janitors, linux-kernel, Ben Skeggs, Daniel Vetter, David Airlie

> … to fix it.

I suggest to replace this wording by the tag “Fixes”.


…
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -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);
> +	}

I propose to move such common exception handling to the end of
this function implementation so that a bit of duplicate code will be avoided.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=e9919e11e219eaa5e8041b7b1a196839143e9125#n481

Regards,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] drm/nouveau: add the missed kfree() for nouveau_bo_alloc()
@ 2020-07-15  9:30 Jing Xiangfeng
  0 siblings, 0 replies; 2+ messages in thread
From: Jing Xiangfeng @ 2020-07-15  9:30 UTC (permalink / raw)
  To: bskeggs, airlied, daniel; +Cc: dri-devel, nouveau, linux-kernel, jingxiangfeng

nouveau_bo_alloc() misses to call kfree() in an error path. Add the
missed function call to fix it.

Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index c40f127de3d0..abd80b1a6de3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-15 18:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 18:12 [PATCH] drm/nouveau: add the missed kfree() for nouveau_bo_alloc() Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-07-15  9:30 Jing Xiangfeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).