From patchwork Thu Oct 8 12:47:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7352451 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 604E89F4DC for ; Thu, 8 Oct 2015 12:48:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59E2920803 for ; Thu, 8 Oct 2015 12:48:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 03FA920802 for ; Thu, 8 Oct 2015 12:47:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D48C6E407; Thu, 8 Oct 2015 05:47:58 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 55E1D6E407 for ; Thu, 8 Oct 2015 05:47:57 -0700 (PDT) Received: by pablk4 with SMTP id lk4so54416618pab.3 for ; Thu, 08 Oct 2015 05:47:56 -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:in-reply-to:references; bh=M8lFT1kAzFnkR/A4yWmgZ4Xf1dnMIZh0LBRzafWI3QM=; b=AaMmcQ7x1WTNE4JLWi2yffwBuzRRgJbRU++kwA8GVEVH287SlIHYKKNSieY/0wSo3B 3DmqED/qQav4bar13BdYbOYIJ36yCTl8XeIf4J0AXfS7+koMaDD+FvGK5MP33P7G6JpK Oo7zbBwKGYj69zbK2uNPKD2s07Dcr4grx5CGv3R/xTYVF2+iJHiEI7op5XLT3kdftdkI yb2VE7bSaQEUhIJvpFKW1lQKSANyWBiZ9dIl1i10zpYRINbMK8VRzy7UFlXw7gzx6ZPw S+VV9rYVgRUulKQbahtfZrkQHazT8XopOkdWyyjUlNdyXgkpCNXYZcdoWEuLkfKH3UYT tqRQ== X-Received: by 10.68.164.98 with SMTP id yp2mr7892773pbb.125.1444308476783; Thu, 08 Oct 2015 05:47:56 -0700 (PDT) Received: from localhost.localdomain ([49.206.251.3]) by smtp.gmail.com with ESMTPSA id rx8sm45365330pbb.90.2015.10.08.05.47.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Oct 2015 05:47:56 -0700 (PDT) From: Sudip Mukherjee To: David Airlie , Daniel Vetter , patrik.r.jakobsson@gmail.com Subject: [PATCH v3] drm/gma500: fix double freeing Date: Thu, 8 Oct 2015 18:17:48 +0530 Message-Id: <1444308468-8910-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444146539-5698-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1444146539-5698-1-git-send-email-sudipm.mukherjee@gmail.com> 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 We are allocating backing using psbfb_alloc() and so backing->stolen is always true. So we were freeing backing two times. Moreover if we follow the execution path then we should be freeing backing after we have released the helper. So remove the one which frees backing before the helper is released. While at it the error labels are also renamed to give a meaningful name. Signed-off-by: Sudip Mukherjee Reviewed-by: Patrik Jakobsson --- drivers/gpu/drm/gma500/framebuffer.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index 2eaf1b3..52e2bf3 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -411,7 +411,7 @@ static int psbfb_create(struct psb_fbdev *fbdev, info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper); if (IS_ERR(info)) { ret = PTR_ERR(info); - goto out_err1; + goto err_unlock; } info->par = fbdev; @@ -419,7 +419,7 @@ static int psbfb_create(struct psb_fbdev *fbdev, ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing); if (ret) - goto out_unref; + goto err_release; fb = &psbfb->base; psbfb->fbdev = info; @@ -465,14 +465,9 @@ static int psbfb_create(struct psb_fbdev *fbdev, mutex_unlock(&dev->struct_mutex); return 0; -out_unref: - if (backing->stolen) - psb_gtt_free_range(dev, backing); - else - drm_gem_object_unreference(&backing->gem); - +err_release: drm_fb_helper_release_fbi(&fbdev->psb_fb_helper); -out_err1: +err_unlock: mutex_unlock(&dev->struct_mutex); psb_gtt_free_range(dev, backing); return ret;