public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: David Airlie <airlied@linux.ie>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	kernel-janitors@vger.kernel.org, Julia Lawall <julia@diku.dk>,
	Ben Skeggs <bskeggs@redhat.com>, Tejun Heo <tj@kernel.org>,
	dri-devel@lists.sourceforge.net
Subject: [patch] nouveau: fix memory leak
Date: Wed, 07 Apr 2010 09:33:36 +0000	[thread overview]
Message-ID: <20100407093336.GE5157@bicker> (raw)

In the original code there was a typo and we called kfree(pgraph->ctxprog)
two times instead of kfree(pgraph->ctxvals);

Also it's OK to pass NULL variables to kfree().  checkpatch.pl complains 
about this so I removed the checks.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.c b/drivers/gpu/drm/nouveau/nouveau_grctx.c
index 32f0e49..06642a5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_grctx.c
+++ b/drivers/gpu/drm/nouveau/nouveau_grctx.c
@@ -134,15 +134,11 @@ nouveau_grctx_fini(struct drm_device *dev)
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
 	struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
 
-	if (pgraph->ctxprog) {
-		kfree(pgraph->ctxprog);
-		pgraph->ctxprog = NULL;
-	}
+	kfree(pgraph->ctxprog);
+	pgraph->ctxprog = NULL;
 
-	if (pgraph->ctxvals) {
-		kfree(pgraph->ctxprog);
-		pgraph->ctxvals = NULL;
-	}
+	kfree(pgraph->ctxvals);
+	pgraph->ctxvals = NULL;
 }
 
 void

                 reply	other threads:[~2010-04-07  9:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20100407093336.GE5157@bicker \
    --to=error27@gmail.com \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=cl@linux-foundation.org \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=tj@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