From patchwork Thu Dec 14 05:41:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archit Taneja X-Patchwork-Id: 10111457 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E7B59602B3 for ; Thu, 14 Dec 2017 05:41:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D96B428D50 for ; Thu, 14 Dec 2017 05:41:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC88A28E96; Thu, 14 Dec 2017 05:41:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEE2528D50 for ; Thu, 14 Dec 2017 05:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751048AbdLNFl5 (ORCPT ); Thu, 14 Dec 2017 00:41:57 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:38842 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbdLNFl4 (ORCPT ); Thu, 14 Dec 2017 00:41:56 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3ADA360117; Thu, 14 Dec 2017 05:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1513230116; bh=FuWJOS/21oTtOHV65qLr6GTjcIo0CqH0YZgLVQhXJ+U=; h=From:To:Cc:Subject:Date:From; b=R6x4akqj+QjP3pY+E3KNxULEFdwYUEbE9ace+ZQ1bAmGaKqiRVVxO0Ue7R2gWkUq+ mDE2/rclfyYy/vQAo77rgUgyRnAJmCqmsPHnG3I8zsQtYKYY7Hu4atdufHfuoO1xTH lxzd6ju+bUM/DKbifxPhwXspR/nkoDKQ7bLL5ro0= Received: from localhost (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: architt@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DB7A560117; Thu, 14 Dec 2017 05:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1513230115; bh=FuWJOS/21oTtOHV65qLr6GTjcIo0CqH0YZgLVQhXJ+U=; h=From:To:Cc:Subject:Date:From; b=QTGVDS6SE3v5iJnZBNGr55JJWwxKz53AcciKqdjXRsn+gru7fe1lGYi7lmDQdH+xF Eb1+9PNbu6eW0fHUm2IqIEEIqXL9w6xIk28POTwYcfhonfOaZjSkQZF+BpHHbucVh8 9pZZhVFrUWVY764hl/49qQ+GodZ7mtwzvWuDKGG0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DB7A560117 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=architt@codeaurora.org From: Archit Taneja To: robdclark@gmail.com Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Archit Taneja Subject: [PATCH] drm/msm: Fix NULL deref in adreno_load_gpu Date: Thu, 14 Dec 2017 11:11:50 +0530 Message-Id: <20171214054150.20943-1-architt@codeaurora.org> X-Mailer: git-send-email 2.15.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Fixes: eec874ce5ff1 (drm/msm/adreno: load gpu at probe/bind time) Signed-off-by: Archit Taneja --- drivers/gpu/drm/msm/adreno/adreno_device.c | 11 +++++++++-- 1 file changed, 9 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..ac60cf3c794e 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -124,10 +124,17 @@ const struct adreno_info *adreno_info(struct adreno_rev rev) 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 platform_device *pdev; + struct msm_gpu *gpu; int ret; + pdev = priv->gpu_pdev; + if (!pdev) { + dev_dbg(dev->dev, "no adreno platform device found\n"); + return NULL; + } + + gpu = platform_get_drvdata(pdev); if (!gpu) { dev_err(dev->dev, "no adreno device\n"); return NULL;