Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9088112pxu; Mon, 28 Dec 2020 06:20:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRvGDHZM9X/XS1SJJwHW8ITZyxbRp7aLGxEm+1z4U9lhXfOy/MO7A299Nn3CLowzZz8W+Q X-Received: by 2002:aa7:ce94:: with SMTP id y20mr41795081edv.361.1609165228080; Mon, 28 Dec 2020 06:20:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165228; cv=none; d=google.com; s=arc-20160816; b=q2NAU4l+g6dDYtHcGZBUpo1ERpOR1xctHQCjHDIvoIzubWK0kwOVwi1EijFyLnhDOs RVfbWa3BkNWnVKTkdqS+/JfOULLTCyZxutNarW42WSbxwPp5KJMxJ6jcF/8Y1iWfR2j9 UIf30rmICRBab1DS077rdE0nS+Db9Iwzr+MmQvlCQZ1NnANC8aDhH0gYL9TIxSINe7Ci whoxiM3gXZXF2/648YQ/P1ptme8qNflgf4PTD9zygJl9gn6bC0C0pbLx3y7RpkJYJ/+f vaKcsddoKfxqJShCqbcfnz4rPSCt0OVLtBzUlAZJB4JDdGXjprKcSLicfIeAKCe1ZR7B AxWA== 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=beYE9MTZW55pMXGxJq9umSm+p45Qq3DVHk7+F6dBIB4=; b=TY4XAARVQAOvspytBNgSfIn1kjdVs80OOH+o14syYUCYJBKm3ZxJx21DasYeqnQkMB GswntH5YXzfp3cvUE1cRtZcEYpVuLWLgiAj1Hr1klMAIrmlBBUgIwibxfElIq35cbVxy azcsOrREv1ZCsymO6aId4M39H6dbdRp16vhJNxJN14/v4vPWctSks/9HHdnf9gDqRBhW OV0/DgPK+PiB9uMqkk+WOvveB88td6IfgfI8UeAvCaoR6INhioQauDTWmLOfMLxjHYe9 3TycIw784lC68RhxQExPQ1qg1YQ38OFn6ZZ4b4PThIO92KEnrXSb/e+8ELjF6My55mPq rFiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tQeF6UYm; 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 g4si20757361eds.170.2020.12.28.06.20.05; Mon, 28 Dec 2020 06:20:28 -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=tQeF6UYm; 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 S2501925AbgL1OST (ORCPT + 99 others); Mon, 28 Dec 2020 09:18:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:53122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441555AbgL1OSS (ORCPT ); Mon, 28 Dec 2020 09:18:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8A4B2242A; Mon, 28 Dec 2020 14:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165083; bh=TKJwtn2LXnMRBEQzWdyVJJO0i6/fXqvbYSbNQuC+hN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tQeF6UYmu8MtXQMlwqOmLc7+EYMxWhv8JjGcW/o1rNkqzzHiyWDnqKpLuFhgFYxZu gC+LIbju9OpHyNoSf0fQLfNTZU+VP5tApzWU8tDGuFigTjmNK7tDF7Fzxa/+SnbMge Z2qJILbbrWQatOqr9bsPjq00klD4UYM6l0Y0yNA8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Changzhong , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.10 404/717] remoteproc: qcom: Fix potential NULL dereference in adsp_init_mmio() Date: Mon, 28 Dec 2020 13:46:42 +0100 Message-Id: <20201228125040.345458626@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Zhang Changzhong [ Upstream commit c3d4e5b12672bbdf63f4cc933e3169bc6bbec8da ] platform_get_resource() may fail and in this case a NULL dereference will occur. Fix it to use devm_platform_ioremap_resource() instead of calling platform_get_resource() and devm_ioremap(). This is detected by Coccinelle semantic patch. @@ expression pdev, res, n, t, e, e1, e2; @@ res = \(platform_get_resource\|platform_get_resource_byname\)(pdev, t, n); + if (!res) + return -EINVAL; ... when != res == NULL e = devm_ioremap(e1, res->start, e2); Fixes: dc160e449122 ("remoteproc: qcom: Introduce Non-PAS ADSP PIL driver") Signed-off-by: Zhang Changzhong Link: https://lore.kernel.org/r/1607392460-20516-1-git-send-email-zhangchangzhong@huawei.com Signed-off-by: Bjorn Andersson Signed-off-by: Sasha Levin --- drivers/remoteproc/qcom_q6v5_adsp.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c b/drivers/remoteproc/qcom_q6v5_adsp.c index f0b7363b5b268..9eb599701f9b0 100644 --- a/drivers/remoteproc/qcom_q6v5_adsp.c +++ b/drivers/remoteproc/qcom_q6v5_adsp.c @@ -364,15 +364,12 @@ static int adsp_init_mmio(struct qcom_adsp *adsp, struct platform_device *pdev) { struct device_node *syscon; - struct resource *res; int ret; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - adsp->qdsp6ss_base = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); - if (!adsp->qdsp6ss_base) { + adsp->qdsp6ss_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(adsp->qdsp6ss_base)) { dev_err(adsp->dev, "failed to map QDSP6SS registers\n"); - return -ENOMEM; + return PTR_ERR(adsp->qdsp6ss_base); } syscon = of_parse_phandle(pdev->dev.of_node, "qcom,halt-regs", 0); -- 2.27.0