From: Dan Carpenter <error27@gmail.com>
To: David Airlie <airlied@linux.ie>
Cc: kernel-janitors@vger.kernel.org,
Emil Velikov <emil.l.velikov@gmail.com>,
Ben Skeggs <bskeggs@redhat.com>,
"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>
Subject: [patch] nouveau: error paths leak in nvc0_graph_construct_context()
Date: Sat, 25 Jun 2011 05:54:46 +0000 [thread overview]
Message-ID: <20110625055446.GT14591@shale.localdomain> (raw)
Two of these error paths returned without freeing "ctx".
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/gpu/drm/nouveau/nvc0_graph.c b/drivers/gpu/drm/nouveau/nvc0_graph.c
index 39e9208..5aa3f9e 100644
--- a/drivers/gpu/drm/nouveau/nvc0_graph.c
+++ b/drivers/gpu/drm/nouveau/nvc0_graph.c
@@ -106,7 +106,8 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
if (!nv_wait(dev, 0x409800, 0x80000000, 0x80000000)) {
NV_ERROR(dev, "PGRAPH: HUB_SET_CHAN timeout\n");
nvc0_graph_ctxctl_debug(dev);
- return -EBUSY;
+ ret = -EBUSY;
+ goto err;
}
} else {
nvc0_graph_load_context(chan);
@@ -119,10 +120,9 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
}
ret = nvc0_grctx_generate(chan);
- if (ret) {
- kfree(ctx);
- return ret;
- }
+ if (ret)
+ goto err;
+
if (!nouveau_ctxfw) {
nv_wr32(dev, 0x409840, 0x80000000);
@@ -131,14 +131,13 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
if (!nv_wait(dev, 0x409800, 0x80000000, 0x80000000)) {
NV_ERROR(dev, "PGRAPH: HUB_CTX_SAVE timeout\n");
nvc0_graph_ctxctl_debug(dev);
- return -EBUSY;
+ ret = -EBUSY;
+ goto err;
}
} else {
ret = nvc0_graph_unload_context_to(dev, chan->ramin->vinst);
- if (ret) {
- kfree(ctx);
- return ret;
- }
+ if (ret)
+ goto err;
}
for (i = 0; i < priv->grctx_size; i += 4)
@@ -146,6 +145,10 @@ nvc0_graph_construct_context(struct nouveau_channel *chan)
priv->grctx_vals = ctx;
return 0;
+
+err:
+ kfree(ctx);
+ return ret;
}
static int
next reply other threads:[~2011-06-25 5:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-25 5:54 Dan Carpenter [this message]
2011-06-25 12:08 ` [patch] nouveau: error paths leak in 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=20110625055446.GT14591@shale.localdomain \
--to=error27@gmail.com \
--cc=airlied@linux.ie \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=kernel-janitors@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox