Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp554691pxb; Wed, 3 Mar 2021 09:26:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyIcxDmb/9TgMH1p27GfF5vd/9bOeLX7OvMWgq/Lb6v77ZthX2eoHKhjDpRARqqD2WA5fT X-Received: by 2002:a17:906:110d:: with SMTP id h13mr24459486eja.357.1614792405957; Wed, 03 Mar 2021 09:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614792405; cv=none; d=google.com; s=arc-20160816; b=w+Rztq8VilrSN0/sPijD76w3dkekSem4wDGSxiFblGIlK6DRUE0tMu7AO/mFyEiH6y KL9Cvamt67UWqCmWNlOSz5c9DLy3xL3o2PezVYJH1Xf9kZ/As4DuME+RDNCv/Ao8UMu8 GFzLVNG2rWh6mG5rhAe3m9GduDt+75e7OywNMFhGbPJPyT/yBUJIoJiB4fxic0mdREvb 3GOUC+j5ytIHnD9ELWilKfNkI2LGsnQ6Fu5bDpUcEG3r3a0Kvjs5hEcTwkESIVjwZYs4 Lu+r+6NoKsDA9PJSiVwqx/4b6On9C4A2Ct20Hj9mrxQiR9VthgnW2EaQAjlMmdPVobvw gmcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aVuvA75Dmr9CnwzVWSdQRTUY2GSCvg97Rh2jDhA6axg=; b=KfQB+fhCRiGREr05dcXCWKrSMJq6FT2Vw4vlF5YWQHyiv6mSQCXbj/1ATenHGz9p9C klBSLj6QksCtdpcCXsU/N4B7DqMGkmTJwTWxH5W4O36/W9mEmYAgfbGXge1IvpnUz/eY X4achvYpf8QKzojrfNLDPSLcMweDla/TxMTmOQ50XfZB624RiofB7J5Bn/jR4oMEfDnd B4LXadWodGTyBQrZcOuCAQSpFFzLxzj/BhiH7gJg+3x4tBwTyvW/qvih5wDasP1UUJHa u6SjR34enkSee7q/Bt2L9XLmTG5WuCkGih34fMtZtImm10AJ7HKC1vkjEoqzdt4617bG g1Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="n4gan/1u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lh6si9906967ejb.613.2021.03.03.09.25.43; Wed, 03 Mar 2021 09:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="n4gan/1u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377300AbhCBAqf (ORCPT + 99 others); Mon, 1 Mar 2021 19:46:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:51554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240172AbhCASl7 (ORCPT ); Mon, 1 Mar 2021 13:41:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC6F664F72; Mon, 1 Mar 2021 17:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614618403; bh=C+lypmXzClL1DQ+g9IH4CZLXoIDxnhDXXUmlOd7aj/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n4gan/1urjiOHz+cx+IGY/dOBI0IPUsPSW+6G+NnQtln+ochVkolr7F7pct90uoUf 6EojXTqmbdG/8QRzdPwq2DEZoz3+95EGRLKpn5HegiMc+GX8L3l4hBnW2Yiv8hYAAK U+aVWepZm5WyhuM0pxZ9HShHRUqPst3AdO+JRfaw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Masney , Luca Weiss , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.10 075/663] soc: qcom: ocmem: dont return NULL in of_get_ocmem Date: Mon, 1 Mar 2021 17:05:23 +0100 Message-Id: <20210301161145.447090044@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luca Weiss [ Upstream commit 01f937ffc4686837d6c43dea80c6ade6cbd2940a ] If ocmem probe fails for whatever reason, of_get_ocmem returned NULL. Without this, users must check for both NULL and IS_ERR on the returned pointer - which didn't happen in drivers/gpu/drm/msm/adreno/adreno_gpu.c leading to a NULL pointer dereference. Reviewed-by: Brian Masney Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver") Signed-off-by: Luca Weiss Link: https://lore.kernel.org/r/20210130142349.53335-1-luca@z3ntu.xyz Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/soc/qcom/ocmem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c index 7f9e9944d1eae..f1875dc31ae2c 100644 --- a/drivers/soc/qcom/ocmem.c +++ b/drivers/soc/qcom/ocmem.c @@ -189,6 +189,7 @@ struct ocmem *of_get_ocmem(struct device *dev) { struct platform_device *pdev; struct device_node *devnode; + struct ocmem *ocmem; devnode = of_parse_phandle(dev->of_node, "sram", 0); if (!devnode || !devnode->parent) { @@ -202,7 +203,12 @@ struct ocmem *of_get_ocmem(struct device *dev) return ERR_PTR(-EPROBE_DEFER); } - return platform_get_drvdata(pdev); + ocmem = platform_get_drvdata(pdev); + if (!ocmem) { + dev_err(dev, "Cannot get ocmem\n"); + return ERR_PTR(-ENODEV); + } + return ocmem; } EXPORT_SYMBOL(of_get_ocmem); -- 2.27.0