From patchwork Wed Jul 17 13:07:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egbert Eich X-Patchwork-Id: 2828595 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C51179F967 for ; Wed, 17 Jul 2013 13:16:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9575C20190 for ; Wed, 17 Jul 2013 13:16:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BBA7F20186 for ; Wed, 17 Jul 2013 13:16:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A378343693 for ; Wed, 17 Jul 2013 06:16:47 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by gabe.freedesktop.org (Postfix) with ESMTP id CAA7CE670D for ; Wed, 17 Jul 2013 06:07:55 -0700 (PDT) Received: from debian (p5DCF2FCF.dip0.t-ipconnect.de [93.207.47.207]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0LnYoV-1UVJdr0QkJ-00hrZN; Wed, 17 Jul 2013 15:07:48 +0200 Received: from sles11.fritz.box (sles11.fritz.box [192.168.178.22]) by debian (Postfix) with ESMTP id 7AF8C47EC; Wed, 17 Jul 2013 15:07:46 +0200 (CEST) From: Egbert Eich To: dri-devel@lists.freedesktop.org Subject: [PATCH 02/16] drm/mgag200: Fix memleak in error path in mgag200_bo_create() Date: Wed, 17 Jul 2013 15:07:15 +0200 Message-Id: <1374066449-21714-3-git-send-email-eich@suse.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1374066449-21714-1-git-send-email-eich@suse.com> References: <1374066449-21714-1-git-send-email-eich@suse.com> X-Provags-ID: V02:K0:kkh96nNKF2+LdsZtptRwxvSqkK/zvwV899z4pf/LkDR 5Ko4p+0XvNDYWbi2lo+9cxpG9MitP0uB6mszhx7r+35YQnneHF 8Gffwl1BOpsk2XgyDW+VMIUg7mNYnD7tryC+SF7gP+/qdoAuPk gey/JUK1Q4alYnjA3He6B1CceBhIpl1xvO2iToeMO8Y9u782u3 5/k+fVdvo7469tJe5WfxZ9dd3V8tpfr+h+bGwuEDBxgRR0o6QC HSRmJOduZfc07y0RMVStNi9re1srHStmI1rY2pHp6UDPfLhvju Tfr6kP6V47kUJm1MuueIC38aSu8UzB4LfqpVfLOtBjDPelaiwU nK+hGQ55TWtZ8faHSse7Q2dGdke/fLja5ECaeId9a Cc: Egbert Eich , Egbert Eich , Mathieu Larouche , Dave Airlie , Christopher Harvey X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The allocated struct mgag200_bo was not freed in all error paths. This patch consolidates error handling and fixes this. Signed-off-by: Egbert Eich --- drivers/gpu/drm/mgag200/mgag200_ttm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c index 3acb2b0..6461fd2 100644 --- a/drivers/gpu/drm/mgag200/mgag200_ttm.c +++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c @@ -316,10 +316,8 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align, return -ENOMEM; ret = drm_gem_object_init(dev, &mgabo->gem, size); - if (ret) { - kfree(mgabo); - return ret; - } + if (ret) + goto err; mgabo->gem.driver_private = NULL; mgabo->bo.bdev = &mdev->ttm.bdev; @@ -334,10 +332,13 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align, align >> PAGE_SHIFT, false, NULL, acc_size, NULL, mgag200_bo_ttm_destroy); if (ret) - return ret; + goto err; *pmgabo = mgabo; return 0; +err: + kfree(mgabo); + return ret; } static inline u64 mgag200_bo_gpu_offset(struct mgag200_bo *bo)