From: Jordan Crouse <jcrouse@codeaurora.org>
To: Archit Taneja <architt@codeaurora.org>
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/msm: Fix NULL deref in adreno_load_gpu
Date: Tue, 2 Jan 2018 11:32:19 -0700 [thread overview]
Message-ID: <20180102183219.GA26197@jcrouse-lnx.qualcomm.com> (raw)
In-Reply-To: <20171222101113.31615-1-architt@codeaurora.org>
On Fri, Dec 22, 2017 at 03:41:13PM +0530, Archit Taneja wrote:
> The msm/kms driver should work even if there is no GPU device specified
> in DT. Currently, we get a NULL dereference crash in adreno_load_gpu
> since the driver assumes that priv->gpu_pdev is non-NULL.
>
> Perform an additional check on priv->gpu_pdev before trying to retrieve
> the msm_gpu pointer from it.
>
> v2: Incorporate Jordan's comments:
> - Simplify the check to share the same error message.
> - Use dev_err_once() to avoid an error message every time we open the
> drm device fd.
>
> Fixes: eec874ce5ff1 (drm/msm/adreno: load gpu at probe/bind time)
>
> Signed-off-by: Archit Taneja <architt@codeaurora.org>
Acked-by: Jordan Crouse <jcrouse@codeaurora.org>
> ---
> drivers/gpu/drm/msm/adreno/adreno_device.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
> index 05022ea2a007..bfb3d689f47d 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_device.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
> @@ -125,11 +125,14 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev)
> {
> struct msm_drm_private *priv = dev->dev_private;
> struct platform_device *pdev = priv->gpu_pdev;
> - struct msm_gpu *gpu = platform_get_drvdata(priv->gpu_pdev);
> + struct msm_gpu *gpu = NULL;
> int ret;
>
> + if (pdev)
> + gpu = platform_get_drvdata(pdev);
> +
> if (!gpu) {
> - dev_err(dev->dev, "no adreno device\n");
> + dev_err_once(dev->dev, "no GPU device was found\n");
> return NULL;
> }
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2018-01-02 18:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 5:41 [PATCH] drm/msm: Fix NULL deref in adreno_load_gpu Archit Taneja
2017-12-15 15:33 ` Jordan Crouse
2017-12-20 6:48 ` Archit Taneja
2017-12-22 10:11 ` [PATCH v2] " Archit Taneja
2018-01-02 18:32 ` Jordan Crouse [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180102183219.GA26197@jcrouse-lnx.qualcomm.com \
--to=jcrouse@codeaurora.org \
--cc=architt@codeaurora.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox