Received: by 10.192.165.156 with SMTP id m28csp69956imm; Tue, 10 Apr 2018 16:37:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4883FAh0vMTwCMRqW8wu5wYc9dUxh7QJ/ZLy3Soe5ZP4zdcfvvKNlIwnQ8ZKNrBE8j6CF4y X-Received: by 2002:a17:902:581e:: with SMTP id m30-v6mr2512564pli.406.1523403476556; Tue, 10 Apr 2018 16:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403476; cv=none; d=google.com; s=arc-20160816; b=A4H2j02C3orBSGhEqbjeGzAW1gjcTWCL7R1CR27bxT/a3hRHebTrWZcTS9CCU/DzSd C6/eXHZyFFjxM/1ejAuzClb8ClNHEm5QBpYNO6UmCvFe1ESYvbKYQMhtP4koo3p66CQo evsYYm9st0KOC+8FWeB6o98+/XHuUY6g3w0mTVMks0YTDqIazDB06chkz6g7CCsQgGAs BPbc9NRo5iaxR9FgssUbzWrSGh/n7M0pvct6gZ1TFMc9y5gi2C89ix4ln6Sl+94opLNf L5Byq/tvxiVFrwnTey+1NCnvytAY4zWh2Aa/fiOhvbv09QMZySEItcJpfUQyrv6riJEl I2og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XvviqZAl8ooJ2seRFemcPK2lc0WpeXofCgXkiSY5tNc=; b=WnhcSwmHbcaJ/SdnQbgweLTI0sVjT6wMHM6ToYI2MmBR4bsH/TDmP3yUIeSIdrErg5 DgTlt/pwvofcbdcOb9DxEhlc3umFVbmEQ8UjoUpH1nC+UIi1scTI9XJJheyFR4aCAOM7 6swuY8ZXTWfh4yABXcWrDnOrop69OveOYBk1xyyRSApG9Wdk5fC9nClaym96qhs1iEOV n01Kub1kyXYHgCcw0k5uzzjWPV3DixV1z8A2377o1WqbC5B5l3d+bnCUObSXnxF29xyH oCsYyRz92xx4aty7DECDnzcXq9HKyQuafzGt4WnKxO45x+oHJMFuDbRbJVWlrhl2R6cY rd5w== ARC-Authentication-Results: i=1; mx.google.com; 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 n8si2464342pgt.480.2018.04.10.16.37.20; Tue, 10 Apr 2018 16:37:56 -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; 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 S1754023AbeDJW2V (ORCPT + 99 others); Tue, 10 Apr 2018 18:28:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38936 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753982AbeDJW2R (ORCPT ); Tue, 10 Apr 2018 18:28:17 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B9341D0B; Tue, 10 Apr 2018 22:28:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Archit Taneja , Jordan Crouse , Rob Clark , Sasha Levin Subject: [PATCH 4.15 036/168] drm/msm: Fix NULL deref in adreno_load_gpu Date: Wed, 11 Apr 2018 00:22:58 +0200 Message-Id: <20180410212801.728309262@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/msm/adreno/adreno_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- 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 d { 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; }