From patchwork Wed Jul 17 13:07:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egbert Eich X-Patchwork-Id: 2828587 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 1ADF49F967 for ; Wed, 17 Jul 2013 13:09:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 734FE200F3 for ; Wed, 17 Jul 2013 13:09:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BB9A62011E for ; Wed, 17 Jul 2013 13:09:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AAA534364D for ; Wed, 17 Jul 2013 06:09:23 -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.17.10]) by gabe.freedesktop.org (Postfix) with ESMTP id D9574E5EC9 for ; Wed, 17 Jul 2013 06:07:50 -0700 (PDT) Received: from debian (p5DCF2FCF.dip0.t-ipconnect.de [93.207.47.207]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0M0AGq-1U9gJk0Ql2-00ujMM; 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 5470E47EB; Wed, 17 Jul 2013 15:07:46 +0200 (CEST) From: Egbert Eich To: dri-devel@lists.freedesktop.org Subject: [PATCH 01/16] drm/mgag200: Fix memleaks in error path in mgag200_fb_create() Date: Wed, 17 Jul 2013 15:07:14 +0200 Message-Id: <1374066449-21714-2-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:LknZJRKNYSx+Uy45tZYXsvNgZp3Uc6M+787JdWn2gAj lCsQKDIbmORxA4x89lDtIYCK7qCORcx6NT1fk6COhA/g7J4tX3 TNL54lW9KTzR7G5+1eLVPz+5ykKSWvUqP0YZq/SYXam/RuxkS5 IBwv4jC2/bq+paHESiKd1wGnOiN8s+4DjPY3AXyVrTmqgHOPkp lVOYdc2ZUpW5mjd4FWZICGww5Ct1JHSwwXum77atkHLzcN9OSR hSEFytocA+W08DINIxhvbAwTKBKaCBY5L1ZLLkWuVJpEq+9D3S hLZzOAbbZqS4zbDW0DYTfAhGCfvqgmkBLsAxLRLyn7OdMQRJn+ erirLX9kOCsxmQBEf6sfQYvlWvRj8U8+4yPqbOwja 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 Some mmemory allocated in mgag200fb_create() was not properly freed before the function returned with an error. This patch takes care of this. Signed-off-by: Egbert Eich --- drivers/gpu/drm/mgag200/mgag200_fb.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index 964f58c..6453e4c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -162,13 +162,13 @@ static int mgag200fb_create(struct drm_fb_helper *helper, struct drm_device *dev = mfbdev->helper.dev; struct drm_mode_fb_cmd2 mode_cmd; struct mga_device *mdev = dev->dev_private; - struct fb_info *info; + struct fb_info *info = NULL; struct drm_framebuffer *fb; struct drm_gem_object *gobj = NULL; struct device *device = &dev->pdev->dev; struct mgag200_bo *bo; int ret; - void *sysram; + void *sysram = NULL; int size; mode_cmd.width = sizes->surface_width; @@ -191,14 +191,16 @@ static int mgag200fb_create(struct drm_fb_helper *helper, return -ENOMEM; info = framebuffer_alloc(0, device); - if (info == NULL) - return -ENOMEM; + if (info == NULL) { + ret = -ENOMEM; + goto out; + } info->par = mfbdev; ret = mgag200_framebuffer_init(dev, &mfbdev->mfb, &mode_cmd, gobj); if (ret) - return ret; + goto out; mfbdev->sysram = sysram; mfbdev->size = size; @@ -242,6 +244,15 @@ static int mgag200fb_create(struct drm_fb_helper *helper, fb->width, fb->height); return 0; out: + mfbdev->mfb.obj = NULL; + vfree(sysram); + mfbdev->sysram = NULL; + if (info && info->cmap.len) + fb_dealloc_cmap(&info->cmap); + framebuffer_release(info); + mfbdev->helper.fb = NULL; + mfbdev->helper.fbdev = NULL; + return ret; }