Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5736161yba; Mon, 13 May 2019 16:43:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHlYasQ/wrLN37KrgL+CvbsWhd94FPfVPZV0Rd2RF6MyF3NwenuzSpZXX2Kmht1jVgZP/7 X-Received: by 2002:a63:318b:: with SMTP id x133mr35024666pgx.297.1557791017080; Mon, 13 May 2019 16:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557791017; cv=none; d=google.com; s=arc-20160816; b=hpmB5Ex1j4nwpbdXQQez5Bf4J+AzkgG1nUGw82m03yoF1jHKi9pwYWN1c+nFy2QGqY txHscegqUMp1vfO8wy0T7HrxE+xjibBiqACRgUyawYs656z2odkh9Loax581Y0rw7pGu k9Ec3PictdwVAJeIvHbD3hr4VFETOotub2e0mOjOpkml5M2gL/58xE8PLSG37Mg8sGBT g6gYakdIqxRl5gjWHjF2ONw4fKyqKnlOEI2ULVctV4VDimd+ExJfnGpkOwv6FvrOocyr AE+43RnCAtuNYbR0Cw2iNjqN5ZBf/D1kTpR6p/fafbHVdAnEhc34IN5Tr/LirRNiKiuA bowg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=AHaVA8uiIzeJMhGR6Nff7BKwXtlBMHsw4ZvE6yJhCqw=; b=CWT888LBL1uzHXjYQPykyg2nmcCiyD730oqDM9zWdTnWT3vm6NUfElFnrRjRwZsR73 0QpLA28o0XJsOC0ldWiJkgOZOWw3c3hI2bdWukQlMwKaffZ2aEchUR9XFA6CBMhRGR0v hsyHwZ9n3i6bFXT4HvFgCDUx9oYLahJS471yuJrmZSMz+WQ9Cq4OrJn1ecChb+53g5FZ odq6KOcpzh31Qk+m3Vbur7fRuLkj6SY58UKLhD756+84Usgn9WGKV2cr97BjVnWRCd22 0Blom+e6yp+oJx51IY55gyijXp8XjzkyxeXHly4GeHYzZ1vHflcm93PEuJoNKm2zw5R2 QRrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@onstation.org header.s=default header.b=MKAflvfH; 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 i2si19313076pgi.0.2019.05.13.16.43.21; Mon, 13 May 2019 16:43:37 -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 (test mode) header.i=@onstation.org header.s=default header.b=MKAflvfH; 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 S1726773AbfEMXlW (ORCPT + 99 others); Mon, 13 May 2019 19:41:22 -0400 Received: from onstation.org ([52.200.56.107]:41244 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726233AbfEMXlU (ORCPT ); Mon, 13 May 2019 19:41:20 -0400 Received: from localhost.localdomain (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id 2F68944970; Mon, 13 May 2019 23:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=onstation.org; s=default; t=1557790879; bh=+8cCOED4KfTSbRV3k/MxI++S4PHLOBvuYlL8f5b9qMU=; h=From:To:Cc:Subject:Date:From; b=MKAflvfHm+VJdLDjRXpxyQ9Q882xYwizApj14wo6NB8V27Gc9f8HB8DqbkiTokWlW /19A8C9U1RIM1hc3JiByxR4A33X1M2gopJH2XOqHMRoCAbcgRMPU8/cRTFAmbyM2sI RfiE1EvJ5a6wXzYWVEvY8NGMgeCFSBqe19CwwI00= From: Brian Masney To: robdclark@gmail.com, sean@poorly.run Cc: bjorn.andersson@linaro.org, dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, airlied@linux.ie, daniel@ffwll.ch, linux-kernel@vger.kernel.org, linus.walleij@linaro.org, jonathan@marek.ca, robh@kernel.org Subject: [PATCH v2.1 1/2] drm/msm: remove resv fields from msm_gem_object struct Date: Mon, 13 May 2019 19:41:04 -0400 Message-Id: <20190513234105.7531-1-masneyb@onstation.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The msm_gem_object structure contains resv and _resv fields that are no longer needed since the reservation object is now stored on drm_gem_object. msm_atomic_prepare_fb() and msm_atomic_prepare_fb() both referenced the wrong reservation object, and would lead to an attempt to dereference a NULL pointer. Correct those two cases to point to the correct reservation object. Signed-off-by: Brian Masney Reviewed-by: Bjorn Andersson Tested-by: Bjorn Andersson Fixes: dd55cf6929e6 ("drm: msm: Switch to use drm_gem_object reservation_object") --- This is a split out version of this patch from where I am working to get the display working on the Nexus 5: https://lore.kernel.org/lkml/20190509020352.14282-2-masneyb@onstation.org/ Bjorn asks: This resolves a NULL-pointer dereference about to show up in v5.2-rc1, so please pick this up for -rc. In this version, I dropped the change to msm_gem_new_impl() that mistakenly removed 'msm_obj->base.resv = resv;'. I did not put a v3 on this patch since I wanted to keep that version number for the larger work to get the display working on the Nexus 5 so I went with 2.1 here. :) drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 4 +--- drivers/gpu/drm/msm/msm_atomic.c | 4 +--- drivers/gpu/drm/msm/msm_gem.h | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c index 4fca24b8702c..f3d009a3dc63 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c @@ -781,7 +781,6 @@ static int dpu_plane_prepare_fb(struct drm_plane *plane, struct dpu_plane_state *pstate = to_dpu_plane_state(new_state); struct dpu_hw_fmt_layout layout; struct drm_gem_object *obj; - struct msm_gem_object *msm_obj; struct dma_fence *fence; struct dpu_kms *kms = _dpu_plane_get_kms(&pdpu->base); int ret; @@ -800,8 +799,7 @@ static int dpu_plane_prepare_fb(struct drm_plane *plane, * implicit fence and fb prepare by hand here. */ obj = msm_framebuffer_bo(new_state->fb, 0); - msm_obj = to_msm_bo(obj); - fence = reservation_object_get_excl_rcu(msm_obj->resv); + fence = reservation_object_get_excl_rcu(obj->resv); if (fence) drm_atomic_set_fence_for_plane(new_state, fence); diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c index f5b1256e32b6..131c23a267ee 100644 --- a/drivers/gpu/drm/msm/msm_atomic.c +++ b/drivers/gpu/drm/msm/msm_atomic.c @@ -49,15 +49,13 @@ int msm_atomic_prepare_fb(struct drm_plane *plane, struct msm_drm_private *priv = plane->dev->dev_private; struct msm_kms *kms = priv->kms; struct drm_gem_object *obj; - struct msm_gem_object *msm_obj; struct dma_fence *fence; if (!new_state->fb) return 0; obj = msm_framebuffer_bo(new_state->fb, 0); - msm_obj = to_msm_bo(obj); - fence = reservation_object_get_excl_rcu(msm_obj->resv); + fence = reservation_object_get_excl_rcu(obj->resv); drm_atomic_set_fence_for_plane(new_state, fence); diff --git a/drivers/gpu/drm/msm/msm_gem.h b/drivers/gpu/drm/msm/msm_gem.h index c5ac781dffee..812d1b1369a5 100644 --- a/drivers/gpu/drm/msm/msm_gem.h +++ b/drivers/gpu/drm/msm/msm_gem.h @@ -86,10 +86,6 @@ struct msm_gem_object { struct llist_node freed; - /* normally (resv == &_resv) except for imported bo's */ - struct reservation_object *resv; - struct reservation_object _resv; - /* For physically contiguous buffers. Used when we don't have * an IOMMU. Also used for stolen/splashscreen buffer. */ -- 2.20.1