From patchwork Sun Jul 3 10:25:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 940832 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 p63AYxd2005828 for ; Sun, 3 Jul 2011 10:35:19 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB9399EB26 for ; Sun, 3 Jul 2011 03:34:58 -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 BB1329E747 for ; Sun, 3 Jul 2011 03:34:50 -0700 (PDT) Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id 7D8189403D; Sun, 3 Jul 2011 12:25:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 7BA639403B; Sun, 3 Jul 2011 12:25:31 +0200 (CEST) Date: Sun, 3 Jul 2011 12:25:31 +0200 (CEST) From: Jesper Juhl To: linux-kernel@vger.kernel.org Subject: [PATCH] nouveau: Do not leak in nv20_graph_create Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Cc: Ben Skeggs , 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 10:35:19 +0000 (UTC) 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"); return 0; } }