From patchwork Mon Sep 7 11:58:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7134051 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 600639F1CD for ; Mon, 7 Sep 2015 11:58:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8EFB120681 for ; Mon, 7 Sep 2015 11:58:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A2B6A20642 for ; Mon, 7 Sep 2015 11:58:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A42B26E69A; Mon, 7 Sep 2015 04:58:39 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 925906E6AB for ; Mon, 7 Sep 2015 04:58:38 -0700 (PDT) Received: by pacfv12 with SMTP id fv12so97897428pac.2 for ; Mon, 07 Sep 2015 04:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IQ7j9W/ZY4G9w/cVY77JkTyC+HwWrLEaVpKE8dkTN6s=; b=jRSQM9pt5zAFkODKKt4d3Raiqq6XTHu7VhMXyfFCG08XVE27iO5VK44N/8Cabm0BoW mq4f35KxKw6YyiOos8Pqhzn25jfqgPlrRTh9UBAttLqOojgsugSwYD062qN0VzXCQ8b9 1Q4Nrk5kuFtsU4yuIyevJSrl2JflPKdrctpMtMZwDxwypjdkDJT6hKpKk1uj8KPqQJ+n rFLRQpiu4kshvgXa9qnyvqaN41EQo4VNJNeKkActxcBZaKfTM6FxGJE37HtHw0sw80ev C9A7o/yGx6oxTV30bDIdbFXlx7KB8Nit6c/xaY700TSqsS05XgTXrMS1AhnGMRWW4zuX S3lQ== X-Received: by 10.66.164.230 with SMTP id yt6mr44422923pab.149.1441627118065; Mon, 07 Sep 2015 04:58:38 -0700 (PDT) Received: from localhost.localdomain ([49.206.245.241]) by smtp.gmail.com with ESMTPSA id gw3sm11784232pbc.46.2015.09.07.04.58.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Sep 2015 04:58:37 -0700 (PDT) From: Sudip Mukherjee To: David Airlie , Daniel Vetter Subject: [PATCH] drm/mgag200: fix memory leak Date: Mon, 7 Sep 2015 17:28:30 +0530 Message-Id: <1441627110-13783-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sudip Mukherjee X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 If drm_fb_helper_alloc_fbi() fails then we were directly returning without freeing sysram. Also if drm_fb_helper_alloc_fbi() succeeds but mgag200_framebuffer_init() fails then we were not releasing sysram and we were not releasing fbi helper also. Signed-off-by: Sudip Mukherjee --- drivers/gpu/drm/mgag200/mgag200_fb.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c index 87de15e..5fe476a 100644 --- a/drivers/gpu/drm/mgag200/mgag200_fb.c +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c @@ -189,14 +189,16 @@ static int mgag200fb_create(struct drm_fb_helper *helper, return -ENOMEM; info = drm_fb_helper_alloc_fbi(helper); - if (IS_ERR(info)) - return PTR_ERR(info); + if (IS_ERR(info)) { + ret = PTR_ERR(info); + goto err_alloc_fbi; + } info->par = mfbdev; ret = mgag200_framebuffer_init(dev, &mfbdev->mfb, &mode_cmd, gobj); if (ret) - return ret; + goto err_framebuffer_init; mfbdev->sysram = sysram; mfbdev->size = size; @@ -226,6 +228,13 @@ static int mgag200fb_create(struct drm_fb_helper *helper, DRM_DEBUG_KMS("allocated %dx%d\n", fb->width, fb->height); return 0; + +err_framebuffer_init: + drm_fb_helper_release_fbi(helper); + +err_alloc_fbi: + vfree(sysram); + return ret; } static int mga_fbdev_destroy(struct drm_device *dev,