From patchwork Tue Oct 6 15:48:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7336601 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DDFCDBEEA4 for ; Tue, 6 Oct 2015 15:49:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05B652074E for ; Tue, 6 Oct 2015 15:49:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1D6DF20715 for ; Tue, 6 Oct 2015 15:49:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B68F6E297; Tue, 6 Oct 2015 08:49:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA36C6E297 for ; Tue, 6 Oct 2015 08:49:10 -0700 (PDT) Received: by pacfv12 with SMTP id fv12so218228604pac.2 for ; Tue, 06 Oct 2015 08:49:10 -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=eqNjCU5a/ifJgGBx5RpzrfoE9NebWAG/tNGYtYDqVuA=; b=AUtLfcy/1KkwLmLQEOBTbGYdvvzbTIzOZamni/pcYOfWcl9PjQ9ZLwz/+d449mamZo ndykChtyqMaFcJz14AQdMPpsokhijZbldukyVSW5ucRDP44v4SifyGm/gUJAokwZPqk0 llPsSORdpcd5c/CKijzGAG513f+cKSyzIWBHgyFL0T2hyGLnV8KotpRifnMZ7Bc/gRfh JCC6CrYkEOGauDxp4vhwVqVJ2ASca/7Fl60OOYXhW8PBCBMUlEk56WyBZMKrnXa4F4MW coLHe7eGU3w2nbU8r2L28mYGo+omIEkMbCkKKGqWS6kDedyKpzGBXA5DbsmmhErXoaan CZsw== X-Received: by 10.68.242.130 with SMTP id wq2mr47457266pbc.117.1444146550291; Tue, 06 Oct 2015 08:49:10 -0700 (PDT) Received: from localhost.localdomain ([49.206.251.3]) by smtp.gmail.com with ESMTPSA id mk5sm34489380pab.44.2015.10.06.08.49.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Oct 2015 08:49:09 -0700 (PDT) From: Sudip Mukherjee To: David Airlie Subject: [PATCH v2] drm/gma500: fix double freeing Date: Tue, 6 Oct 2015 21:18:59 +0530 Message-Id: <1444146539-5698-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: Daniel Vetter , 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. Cc: Patrik Jakobsson Signed-off-by: Sudip Mukherjee Reviewed-by: Patrik Jakobsson --- Hi Patrik, If you donot like the labels I will change them according to what you have suggested. 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_alloc_fbi; } 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_framebuffer_init; 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_framebuffer_init: drm_fb_helper_release_fbi(&fbdev->psb_fb_helper); -out_err1: +err_alloc_fbi: mutex_unlock(&dev->struct_mutex); psb_gtt_free_range(dev, backing); return ret;