Received: by 10.213.65.68 with SMTP id h4csp1861301imn; Mon, 19 Mar 2018 15:32:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELtgs3I97yyCsGqynHbT1ENGa4hsncH7EO9A1CHg+2ZIE9GJpMxWGsJ+LHxJ7LNoy6Kab2p5 X-Received: by 10.98.189.24 with SMTP id a24mr11680637pff.125.1521498722071; Mon, 19 Mar 2018 15:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521498722; cv=none; d=google.com; s=arc-20160816; b=bO4A9aDxpLbYnpVtgKs2zI1NsvGBfwGUrDlVAiU0qQwCMW1OlrEs8Q/IJWGIlRyNqK HttG9p1FG4eN2uItyyMpH7vgkkUwHk8zSHvDkSkkhYJZGoFQ3e1c2FvqN42Dpuuq45hO RfgUb4sezqZq3QgozGXQSg9c6uUemUkU9/W76czAUoKYfnzMS4GNiwbsYeF+mehH27HH pl5zf9QpUjityMuerZHTTjR+5opM11HvMMPkp6Eps2FqJKR1/v6mutNQjChJFjOKAGN/ fj5VeshhGiWYE7C4XAhZ0Nofveprq/uthf+VYDINbqxFhW1mSLct5RnTgbHCYGgdSC61 vEmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=EfvyHPJKQG6aSJZL8QAZeqFDqTr3ET3y6lGfB7BuWsc=; b=k/lTn/+GC5/8gNE9unewOmGcA9B7jf7JX+ZMfrJuouxG2yklDw2iCvoqNY/d1uyZL7 cQP4kGnxDoiM2B27GeN4yWJSOtsqriGuPtGLQTwcrSgS04clvrZjI1Ii3wSjoI6RBaP1 NB15Du7cfA6iEM/4OWpR1pghNfztc+qTbJ39sEX2Dx5GjYk57GXjeVsp+OSdr35U6fq7 rcjjaHZ7ZldL2s2O7hzx4WuYgQ5iz23YCRw9gcS44jbttUzJB8OVDEWmyLxCWoGYIDIE vw9HxXuA4jyPlh8dBxU0aw7/FQnE5Cl4oLrriStVmIz20+LYFX6mSMj0CpA7dZ9eP6xL REog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YziISiTH; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13-v6si210835pll.416.2018.03.19.15.31.48; Mon, 19 Mar 2018 15:32:02 -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=@microsoft.com header.s=selector1 header.b=YziISiTH; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S972451AbeCSWaM (ORCPT + 99 others); Mon, 19 Mar 2018 18:30:12 -0400 Received: from mail-by2nam01on0106.outbound.protection.outlook.com ([104.47.34.106]:41792 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933784AbeCSPsc (ORCPT ); Mon, 19 Mar 2018 11:48:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=EfvyHPJKQG6aSJZL8QAZeqFDqTr3ET3y6lGfB7BuWsc=; b=YziISiTHR1iwGmhFbubjzfhUeAy7qa8sMdG8FURGqSrBysUwSILGAhsqOZoNjM6EFDtXM9kFl+YOZ/pmN2gi6lfTTVwjm1k3C5wV8cls1/YbulgWai9GtP8qNprhG0ZWEzHuDJSawSY1id7urZmUMcrlmIGK5TY0ST/157OErFk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1030.namprd21.prod.outlook.com (52.132.128.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.1; Mon, 19 Mar 2018 15:48:05 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:48:05 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Archit Taneja , Rob Clark , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 038/124] drm/msm: Fix NULL deref in adreno_load_gpu Thread-Topic: [PATCH AUTOSEL for 4.15 038/124] drm/msm: Fix NULL deref in adreno_load_gpu Thread-Index: AQHTv5mb5CwE9tlgT02e6XgMUdHekA== Date: Mon, 19 Mar 2018 15:47:38 +0000 Message-ID: <20180319154645.11350-38-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1030;7:sHlOoXUTBFcl+Ac4FmAX7G+xKXFKrygJbM82J+kutZ8JXd1p/7lGhkmMwU85WxiFCaC5tz3g8IBFfB9wIEEjYjqGVt5CFVw842JhrPVSWqRdxSqC8yaKMRZPtQq91VIgsvsrhzGvbH1MywqaYhcvx6y4+UTibP/4X9r6LhLSIROCMBPsUDvFsNoClEvTrXkgk1ssBth12k/6f4slVUvSZKMQaXGafHUYLCMcBD8IxtM08pAkQbXNeHHi5RfIDSmq;20:yyarYxpGhL2JfgSS0tYwyo/hjJor5kMq9hu4cKq+U5WEXoVqpYKYwvViv71YgAqK16IvmpXyYEeLDlYfQS95LFYuX9TG+IGyPmMRQlhbhpLUv8srIUlgPviCO/5tGpnqY8emFa0ImLNWW408UrA4FUsLkPJqQkFGDFXiCgQ80r4= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: cfbea06c-7bfd-4bf3-7638-08d58db0ce5a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1030; x-ms-traffictypediagnostic: DM5PR2101MB1030: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231221)(944501300)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB1030;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1030; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(396003)(39380400002)(366004)(346002)(376002)(199004)(189003)(2501003)(6486002)(5250100002)(478600001)(86612001)(102836004)(1076002)(97736004)(575784001)(99286004)(72206003)(6436002)(2906002)(107886003)(66066001)(10090500001)(81166006)(6116002)(81156014)(305945005)(8676002)(86362001)(7736002)(68736007)(54906003)(110136005)(26005)(3846002)(105586002)(3280700002)(316002)(53936002)(8936002)(186003)(39060400002)(76176011)(2900100001)(6506007)(36756003)(10290500003)(2950100002)(22452003)(25786009)(5660300001)(106356001)(3660700001)(4326008)(14454004)(6512007)(6666003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1030;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: gkESxPIxjxNczPQrvPQUcqmZNtjswRhA5f2MmyiaKKG3GWE3qsIoopM32QOnJ7ofJFBIMy132OGGyViQt/Ui32f3j9VRJECQSHvr1JvEwlLEvSrwNH5jHS49KSOhbY6JEf4lULZifn2N7fiv2iawNkRVvtK4Bg+lias9WeOMppr/9eDeQWstb9wZrKbTW0BC/1pfKyCy9KppSfLfJUmUZ9iFGvpSL6hZ/kLfsPqJipmL2YYtK55vQY9/Kgg+5zVI7TQb+dWIQfsK5OjbSS/ysynalOk6JtVgKqgl8p2f1wC9LNctIPRtBI1pRr6Yyv+XM72GABOiy5lx+P1Sx24UIg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: cfbea06c-7bfd-4bf3-7638-08d58db0ce5a X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:47:38.6878 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1030 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Archit Taneja [ Upstream commit 9dcfbc182f1aac0aa5ea194733d21e67dd2ba1fd ] 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 Acked-by: Jordan Crouse Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- 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/m= sm/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 *de= v) { struct msm_drm_private *priv =3D dev->dev_private; struct platform_device *pdev =3D priv->gpu_pdev; - struct msm_gpu *gpu =3D platform_get_drvdata(priv->gpu_pdev); + struct msm_gpu *gpu =3D NULL; int ret; =20 + if (pdev) + gpu =3D 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; } =20 --=20 2.14.1