From patchwork Sun Jul 3 11:21:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 940862 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p63BVTPX009078 for ; Sun, 3 Jul 2011 11:31:50 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 50C319E961 for ; Sun, 3 Jul 2011 04:31:24 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from swampdragon.chaosbits.net (swampdragon.chaosbits.net [90.184.90.115]) by gabe.freedesktop.org (Postfix) with ESMTP id EAF369E732 for ; Sun, 3 Jul 2011 04:31:14 -0700 (PDT) Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id 7594E9403E; Sun, 3 Jul 2011 13:21:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 6DE1D9403B; Sun, 3 Jul 2011 13:21:55 +0200 (CEST) Date: Sun, 3 Jul 2011 13:21:55 +0200 (CEST) From: Jesper Juhl To: Paul Menzel Subject: Re: [PATCH] nouveau: Do not leak in nv20_graph_create In-Reply-To: Message-ID: References: <1309690311.20270.27.camel@mattotaupa> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 03 Jul 2011 11:31:50 +0000 (UTC) On Sun, 3 Jul 2011, Jesper Juhl wrote: > On Sun, 3 Jul 2011, Paul Menzel wrote: > > > Dear Jesper, > > > > > > Am Sonntag, den 03.07.2011, 12:25 +0200 schrieb Jesper Juhl: > > > 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. > > > > > > Signed-off-by: Jesper Juhl > > > --- > > > drivers/gpu/drm/nouveau/nv20_graph.c | 4 +++- > > > 1 files changed, 3 insertions(+), 1 deletions(-) > > > > > > Don't have the hardware, so compile tested only. > > > > > > diff --git a/drivers/gpu/drm/nouveau/nv20_graph.c b/drivers/gpu/drm/nouveau/nv20_graph.c > > > index affc7d7..059ad65 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: unknown chipset.\n"); > > > > so the only disambiguation is the full stop at the end? > > > Yeah. I guess I could have reworded the text, but I settled on just adding > that "."... > I guess this is better : From: Jesper Juhl 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. Signed-off-by: Jesper Juhl --- 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; } }