From: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/nouveau: fix error handling in core/core object creation functions
Date: Mon, 8 Oct 2012 01:01:00 +0200 [thread overview]
Message-ID: <20121007230100.GA25474@joi.lan> (raw)
In-Reply-To: <1349650171-25045-5-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Mon, Oct 08, 2012 at 12:49:31AM +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> This patch relies on "drm/nouveau: remove >1 sclass support from nouveau_parent_create_".
>
> There are *many* *more* code paths without proper error handling - I counted
> at least 106 in 41 functions. If someone would like to do a bit of janitorial
> work I marked those code paths and uploaded "patch" here:
> http://people.freedesktop.org/~mslusarz/0001-codepaths-without-error-handling.patch
> (Please let me know if you are going to fix those to not duplicate work)
> ---
> drivers/gpu/drm/nouveau/core/core/engine.c | 1 +
> drivers/gpu/drm/nouveau/core/core/gpuobj.c | 9 ++++++---
> drivers/gpu/drm/nouveau/core/core/parent.c | 4 +++-
> 3 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/core/core/engine.c b/drivers/gpu/drm/nouveau/core/core/engine.c
> index 09b3bd5..4319854 100644
> --- a/drivers/gpu/drm/nouveau/core/core/engine.c
> +++ b/drivers/gpu/drm/nouveau/core/core/engine.c
> @@ -44,6 +44,7 @@ nouveau_engine_create_(struct nouveau_object *parent,
> return ret;
>
> if (!nouveau_boolopt(device->cfgopt, iname, enable)) {
> + nouveau_subdev_destroy(&engine->base);
> if (!enable)
> nv_warn(engine, "disabled, %s=1 to enable\n", iname);
> return -ENODEV;
> diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> index c2a7608..6254d52 100644
> --- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> +++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
> @@ -40,7 +40,7 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
> }
>
> if (gpuobj->heap.block_size)
> - nouveau_mm_fini(&gpuobj->heap);
> + WARN_ON(nouveau_mm_fini(&gpuobj->heap));
Ha! This is triggering on channel close. Maybe it's the leak which is
preventing piglit from finishing...
>
> nouveau_object_destroy(&gpuobj->base);
> }
> @@ -113,7 +113,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
> ret = nouveau_mm_head(heap, 1, size, size,
> max(align, (u32)1), &gpuobj->node);
> if (ret)
> - return ret;
> + goto err;
>
> gpuobj->addr += gpuobj->node->offset;
> }
> @@ -121,7 +121,7 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
> if (gpuobj->flags & NVOBJ_FLAG_HEAP) {
> ret = nouveau_mm_init(&gpuobj->heap, 0, gpuobj->size, 1);
> if (ret)
> - return ret;
> + goto err;
> }
>
> if (flags & NVOBJ_FLAG_ZERO_ALLOC) {
> @@ -130,6 +130,9 @@ nouveau_gpuobj_create_(struct nouveau_object *parent,
> }
>
> return ret;
> +err:
> + nouveau_gpuobj_destroy(gpuobj);
> + return ret;
> }
>
> struct nouveau_gpuobj_class {
> diff --git a/drivers/gpu/drm/nouveau/core/core/parent.c b/drivers/gpu/drm/nouveau/core/core/parent.c
> index 1a48e58..d2ea7c2 100644
> --- a/drivers/gpu/drm/nouveau/core/core/parent.c
> +++ b/drivers/gpu/drm/nouveau/core/core/parent.c
> @@ -87,8 +87,10 @@ nouveau_parent_create_(struct nouveau_object *parent,
>
> if (sclass && sclass->ofuncs) {
> nclass = kzalloc(sizeof(*nclass), GFP_KERNEL);
> - if (!nclass)
> + if (!nclass) {
> + nouveau_parent_destroy(object);
> return -ENOMEM;
> + }
>
> nclass->sclass = object->sclass;
> object->sclass = nclass;
> --
> 1.7.12
>
next prev parent reply other threads:[~2012-10-07 23:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-07 22:49 [PATCH] drm/nouveau: fix error handling in core/core object creation functions Marcin Slusarz
[not found] ` <1349650171-25045-5-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-07 23:01 ` Marcin Slusarz [this message]
2012-10-08 1:05 ` Ben Skeggs
[not found] ` <20121008010533.GA4197-6RkuLLNOGXsZ315U/fw+0NvLeJWuRmrY@public.gmane.org>
2012-10-08 22:50 ` Marcin Slusarz
[not found] ` <20121008225059.GD3103-OI9uyE9O0yo@public.gmane.org>
2012-10-09 0:05 ` Ben Skeggs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121007230100.GA25474@joi.lan \
--to=marcin.slusarz-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.