Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp500273yba; Mon, 1 Apr 2019 10:32:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqynnKyCWyKwDR3OWiXtCuEAMApVN3Fg8gi1CJBtdoAtgBNB6CWZpu9HtcOf3B/ZGdqcYvth X-Received: by 2002:aa7:8390:: with SMTP id u16mr62581223pfm.63.1554139951795; Mon, 01 Apr 2019 10:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554139951; cv=none; d=google.com; s=arc-20160816; b=xY2WdzWPD9QyPHMk5zeyYtIrdlivxcl3JXjMyA5rYezWnonEgwsJ5lVsHQPMtW7VGQ 76MVhxt7q8Ld0OLFOIce5AlAnRyfpvsYbQhZRilP59rHwzLzcaR8j9203UYVE6TcY/2c r312oCxEyWQcU50VjtrIgwVkJ+8bT69/RU0V2kEPw+iVWdB0q1IEG7c8U9VgV2cpPVpX JKxWZwclRjYhZ1SPuOaBoUZLIl1Xv4Bzvaa8j3DiNEp6jAwCjiQpKzf8JRlm28rKcWT9 lCwhmzABbNWIJH6h8mncL1HYvDQwlbmsQttlnTx8kQ21yFPSSmZg7pJirbMIaJ45r+01 0i4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nl1hkBqMPWbReKKYPCOe+y0xyxyesoyAHhi/2GRAvas=; b=QPv/oCX/WFzdhenhxi49/A2VP9ddvb+N9tXrnIMIHpHcOOwuoyhWvDOp0K8TcBcLtK 3PecA/UTfS2r4iGn0m/unXV29jc3iUXe8jaaHPyb4NoD6SVBLKAaWlS94o0tUJkwG+JX wVpES1dtVSmPAb/nlj0kXn7uNg8fyhFCaD9GZdWjzU4cyIagzwo/06oMLuFuUCMZoUGV ixO+Q7gwEeCJTEnYyFZfmd1o9MOuasgOFrgR3HbUPWv5n9DVqPi14+4mtW1wW2pcBQGK 5+6hP2mpB+6A5oGa0rlIhbP2UPCU5gAl/5adcYqYsQ/FklcPJt63DgTFpb5MjtwF6SDP uj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LfBWlmFH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6si9405129plf.356.2019.04.01.10.32.16; Mon, 01 Apr 2019 10:32:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LfBWlmFH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733284AbfDARbk (ORCPT + 99 others); Mon, 1 Apr 2019 13:31:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:39236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733078AbfDARbi (ORCPT ); Mon, 1 Apr 2019 13:31:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 269132070B; Mon, 1 Apr 2019 17:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554139897; bh=nY9Tg0EwRZUB7q4YUmtswoKzuzRFM1oxQZVHDHNo0xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LfBWlmFHuPBiMxQgv1yk0FHLCd2ZCr4i3QP1vZ1kTd9dffXW55Mx2ngEbuCvv+C5R 5hm12RBI1D9hbhcv0NZLAPZjv2Kj1s47IaYnBQJdaun+c5ajzTwIQB4rXUEaPAU4gz Qkym+GM04vGHfvv/TY8f985IHCWxH6wKlHeJX2H8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Zimmermann , Deepak Rawat , Thomas Hellstrom Subject: [PATCH 4.4 002/131] drm/vmwgfx: Dont double-free the mode stored in par->set_mode Date: Mon, 1 Apr 2019 19:01:12 +0200 Message-Id: <20190401170051.875045312@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170051.645954551@linuxfoundation.org> References: <20190401170051.645954551@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Zimmermann commit c2d311553855395764e2e5bf401d987ba65c2056 upstream. When calling vmw_fb_set_par(), the mode stored in par->set_mode gets free'd twice. The first free is in vmw_fb_kms_detach(), the second is near the end of vmw_fb_set_par() under the name of 'old_mode'. The mode-setting code only works correctly if the mode doesn't actually change. Removing 'old_mode' in favor of using par->set_mode directly fixes the problem. Cc: Fixes: a278724aa23c ("drm/vmwgfx: Implement fbdev on kms v2") Signed-off-by: Thomas Zimmermann Reviewed-by: Deepak Rawat Signed-off-by: Thomas Hellstrom Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c @@ -531,11 +531,9 @@ static int vmw_fb_set_par(struct fb_info 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) }; - struct drm_display_mode *old_mode; struct drm_display_mode *mode; int ret; - old_mode = par->set_mode; mode = drm_mode_duplicate(vmw_priv->dev, &new_mode); if (!mode) { DRM_ERROR("Could not create new fb mode.\n"); @@ -546,11 +544,7 @@ static int vmw_fb_set_par(struct fb_info mode->vdisplay = var->yres; vmw_guess_mode_timing(mode); - if (old_mode && drm_mode_equal(old_mode, mode)) { - drm_mode_destroy(vmw_priv->dev, mode); - mode = old_mode; - old_mode = NULL; - } else if (!vmw_kms_validate_mode_vram(vmw_priv, + if (!vmw_kms_validate_mode_vram(vmw_priv, mode->hdisplay * DIV_ROUND_UP(var->bits_per_pixel, 8), mode->vdisplay)) { @@ -613,8 +607,8 @@ static int vmw_fb_set_par(struct fb_info schedule_delayed_work(&par->local_work, 0); out_unlock: - if (old_mode) - drm_mode_destroy(vmw_priv->dev, old_mode); + if (par->set_mode) + drm_mode_destroy(vmw_priv->dev, par->set_mode); par->set_mode = mode; drm_modeset_unlock_all(vmw_priv->dev);