From patchwork Sat Jun 25 05:54:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 918092 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5P5tl5i007971 for ; Sat, 25 Jun 2011 05:56:07 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C19099EDD9 for ; Fri, 24 Jun 2011 22:55:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pw0-f49.google.com (mail-pw0-f49.google.com [209.85.160.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EFDC9E746 for ; Fri, 24 Jun 2011 22:55:37 -0700 (PDT) Received: by pwi3 with SMTP id 3so2518994pwi.36 for ; Fri, 24 Jun 2011 22:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=f7oPovQhnpMDXRQjAmHYgOcZ7qXauMIT3yPXFwJwIRs=; b=CsqS5EVNI/5oWbonAdyDdYCaapjFI6S+Xx5RM/3kr3mceO0/0borrMBr/+eO3gAjCm Hc28aclDVVxnqamJAt6GRRqI/y+afpreFvqjA2/Sc5QkgVihSmd+2zcpaaOVIf17Bm2u UQAgpt4AjK2Ubdz5o+ZgEEwq0rk3DpfsTIj6o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=P6j2RMo7x39qficxYVE1RTgYQ4wXMGdDlZJ5BQF+2MOPWgfhKYGQzcI03JpzuSrBux pxWgYegILtng4xI4knvz4b3OTCVi3n7WhqhzNVTpBCQnQFlcE4jrmmKH2eltZ0gWPALC W7ZY3T+seeIdLqojNq61gSrM6TGgQAM3zCucs= Received: by 10.68.43.233 with SMTP id z9mr2281068pbl.211.1308981337293; Fri, 24 Jun 2011 22:55:37 -0700 (PDT) Received: from shale.localdomain ([41.139.221.94]) by mx.google.com with ESMTPS id u6sm2612471pbh.64.2011.06.24.22.55.32 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 22:55:36 -0700 (PDT) Date: Sat, 25 Jun 2011 08:54:46 +0300 From: Dan Carpenter To: David Airlie Subject: [patch] nouveau: error paths leak in nvc0_graph_construct_context() Message-ID: <20110625055446.GT14591@shale.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: kernel-janitors@vger.kernel.org, Emil Velikov , Ben Skeggs , "open list:DRM DRIVERS" 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 (demeter1.kernel.org [140.211.167.41]); Sat, 25 Jun 2011 05:56:07 +0000 (UTC) Two of these error paths returned without freeing "ctx". Signed-off-by: Dan Carpenter 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