Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3481746pxb; Mon, 4 Apr 2022 18:21:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjt41LIMeWLq7riR73qeeXpUg0kD1+3pKDOkZju+s4lqto0gn5CTNChqrV9aJyScRQZ1Ip X-Received: by 2002:a17:903:40c7:b0:156:8b56:5fa1 with SMTP id t7-20020a17090340c700b001568b565fa1mr1021998pld.108.1649121709360; Mon, 04 Apr 2022 18:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649121709; cv=none; d=google.com; s=arc-20160816; b=0CIXKjDqHhDvFSs47JPhjkgI8XPe3fDC9Smlglg1okeyuWUlEfIHH+ImlMi9dYxhJm T50mpmZbJIDnH6WV/VtIWaRlRVTDTLcCPiUO9yt/k3xiJfNC/dzg2PtZNEAN6kgmTdfO kvwBLkDH3hF7y0itq3mdPdvOzS/KXZEFMkNL0U2O3Y5KLCJmBdXG5dwxycEu0P59aDtw 5B67GQ38CY6Mt6oCN+E01TZ7iVP52ov1HvPetZAZClnqON22F70LBWyoj+7FY1KJXdpR UqRJ6xaCFSZB6JK6pUs5pjDGFvydIf338+n3/HxF79HxChhfh9V++i3fS78i6uQqRhyQ hMwA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rzHAiQz1dTUTk8TRs3STJlt8cZouaon+JnlcToia7aE=; b=0tCbaUkebxAI1E1V1+69JTNctB6YLSvdC1A873FFjqkBuj+u0rRqZHuzKWpRnDPI4b AG1ohuVRXYLdxapdH8e7/J1FYTzxPxpKzoQktf6XqrRJgT6XgxXKhTj3sJb3uPlcsoaC or3SXH1uVxZvNvVSCHlMl00mxp4DKzSftKZypPmNqyUf+fTJ+GwA2t5VQ3W5uziPAjBP Mi/UtLvXi1Y2ZU6qnCnjOkJiEVqXgx9xyWWLmSb6UrQmG05BJfiMKJbKV2+cCj3auFOA KQ/zE5d+aXHoaCrhgI+KgAMjOJXwKFA+GXWBpik2k4LbQ0Ip4fDxE0LRC7n5eA5FdOhr HSiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iY0HzFuP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 32-20020a630a20000000b00398b859041esi11564777pgk.255.2022.04.04.18.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:21:49 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iY0HzFuP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A7039182AEA; Mon, 4 Apr 2022 17:13:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348015AbiDAOgy (ORCPT + 99 others); Fri, 1 Apr 2022 10:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347554AbiDAOdL (ORCPT ); Fri, 1 Apr 2022 10:33:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBB18231ACC; Fri, 1 Apr 2022 07:29:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9452EB82500; Fri, 1 Apr 2022 14:29:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9540EC2BBE4; Fri, 1 Apr 2022 14:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648823379; bh=eTiovVUCen7xNYJkwiLrMjheRNdT5H42VgeNdAbVmjY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iY0HzFuPYi+s0imDltpHRMocEkETTYKm61R7TfU9XFe15ev2tKsadFIjBfhl02lFb 23Zuo9dtQXdKg2SKm4hEkFbkAkGGY9G0VYyf47ZzNoUnSElMYsUk9RE5Q7HERRH4ZW YTxKYiAJMgDnmwbkGH5JxnSajZcke2nAzp/n4lnJ3CUijcxBISuDYSUFKn3LAuhmml /J4LHvSbXLRPQZuUHesQDza/22Wo6Zqtl4a0ARA8Zxb0VtfVa9EKWUWIdzRsiUIazw vToQivUPl2eEwt3uE159IXhUMAd/kZ3K8dpM5JaEt/A/xJspaRvmH9T4MfgQ+dEUg+ /yiJY+DNBxAFA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kevin Tang , Zou Wei , Javier Martinez Canillas , Thomas Zimmermann , Sasha Levin , airlied@linux.ie, daniel@ffwll.ch, orsonzhai@gmail.com, baolin.wang7@gmail.com, zhang.lyra@gmail.com, maarten.lankhorst@linux.intel.com, maxime@cerno.tech, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.17 072/149] drm/sprd: check the platform_get_resource() return value Date: Fri, 1 Apr 2022 10:24:19 -0400 Message-Id: <20220401142536.1948161-72-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401142536.1948161-1-sashal@kernel.org> References: <20220401142536.1948161-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kevin Tang [ Upstream commit 73792e6e66be1225837cc1a40f1e39b1d077751c ] platform_get_resource() may fail and return NULL, so check it's value before using it. Reported-by: Zou Wei Signed-off-by: Kevin Tang Reviewed-by: Javier Martinez Canillas Acked-by: Thomas Zimmermann Link: https://lore.kernel.org/all/20220117084156.9338-1-kevin3.tang@gmail.com v1 -> v2: - new patch Signed-off-by: Sasha Levin --- drivers/gpu/drm/sprd/sprd_dpu.c | 5 +++++ drivers/gpu/drm/sprd/sprd_dsi.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/sprd/sprd_dpu.c b/drivers/gpu/drm/sprd/sprd_dpu.c index 06a3414ee43a..1637203ea103 100644 --- a/drivers/gpu/drm/sprd/sprd_dpu.c +++ b/drivers/gpu/drm/sprd/sprd_dpu.c @@ -790,6 +790,11 @@ static int sprd_dpu_context_init(struct sprd_dpu *dpu, int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "failed to get I/O resource\n"); + return -EINVAL; + } + ctx->base = devm_ioremap(dev, res->start, resource_size(res)); if (!ctx->base) { dev_err(dev, "failed to map dpu registers\n"); diff --git a/drivers/gpu/drm/sprd/sprd_dsi.c b/drivers/gpu/drm/sprd/sprd_dsi.c index 911b3cddc264..12b67a5d5923 100644 --- a/drivers/gpu/drm/sprd/sprd_dsi.c +++ b/drivers/gpu/drm/sprd/sprd_dsi.c @@ -907,6 +907,11 @@ static int sprd_dsi_context_init(struct sprd_dsi *dsi, struct resource *res; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "failed to get I/O resource\n"); + return -EINVAL; + } + ctx->base = devm_ioremap(dev, res->start, resource_size(res)); if (!ctx->base) { drm_err(dsi->drm, "failed to map dsi host registers\n"); -- 2.34.1