All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Paul Menzel <paulepanter@users.sourceforge.net>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] nouveau: Do not leak in nv20_graph_create
Date: Sun, 3 Jul 2011 16:39:13 +0200	[thread overview]
Message-ID: <20110703143913.GA3217@joi.lan> (raw)
In-Reply-To: <alpine.LNX.2.00.1107031321150.18279@swampdragon.chaosbits.net>

On Sun, Jul 03, 2011 at 01:21:55PM +0200, Jesper Juhl wrote:
> From: Jesper Juhl <jj@chaosbits.net>
> Subject: [PATCH] nouveau: Do not leak in nv20_graph_create
> 
> If we return due to an unknown chipset in drivers/gpu/drm/nouveau/nv20_graph.c:nv20_graph_create() we'll leak the memory allocated to 'pgraph'.
> 
> This patch should fix the leak and it also disambiguates the "PGRAPH:
> unknown chipset\n" error message - it's nice to be able to tell which
> branch created the error which is impossible if the error messages are
> 100% identical.

There's no need to change these strings. Nouveau prints chipset id earlier.
For patch with only kfrees:
Reviewed-by: Marcin Slusarz <marcin.slusarz@gmail.com>

> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  drivers/gpu/drm/nouveau/nv20_graph.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c
> index affc7d7..53cbe84 100644
> --- a/drivers/gpu/drm/nouveau/nv20_graph.c
> +++ b/drivers/gpu/drm/nouveau/nv20_graph.c
> @@ -752,6 +752,7 @@ nv20_graph_create(struct drm_device *dev)
>  			pgraph->grctx_user = 0x0000;
>  			break;
>  		default:
> +			kfree(pgraph);
>  			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
>  			return 0;
>  		}
> @@ -773,7 +774,8 @@ nv20_graph_create(struct drm_device *dev)
>  			pgraph->grctx_size = NV35_36_GRCTX_SIZE;
>  			break;
>  		default:
> -			NV_ERROR(dev, "PGRAPH: unknown chipset\n");
> +			kfree(pgraph);
> +			NV_ERROR(dev, "PGRAPH: chipset unknown.\n");
>  			return 0;
>  		}
>  	}
> -- 

  reply	other threads:[~2011-07-03 14:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-03 10:25 [PATCH] nouveau: Do not leak in nv20_graph_create Jesper Juhl
2011-07-03 10:51 ` Paul Menzel
2011-07-03 10:51   ` Paul Menzel
2011-07-03 11:16   ` Jesper Juhl
2011-07-03 11:21     ` Jesper Juhl
2011-07-03 14:39       ` Marcin Slusarz [this message]
2011-07-03 23:46         ` 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=20110703143913.GA3217@joi.lan \
    --to=marcin.slusarz@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulepanter@users.sourceforge.net \
    /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.