Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp619571iog; Mon, 13 Jun 2022 09:16:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRA2wR8NUnGot/7WmB9vOu96THrsEOmHs1C6F4oi1qMU0d4m8Q26Szbj6+12+2fIbcQ4c0 X-Received: by 2002:a62:d045:0:b0:51b:fcf6:3add with SMTP id p66-20020a62d045000000b0051bfcf63addmr102455pfg.68.1655136985866; Mon, 13 Jun 2022 09:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655136985; cv=none; d=google.com; s=arc-20160816; b=RDJMMf/Mo8iXCCF1PlnMeGZqnaaexFVthjX8sGBBAiKjKKivzSqkThPv0z0WGuQJyQ iIPXdr7BjhoYOtBPj6cWaYFJfP/SgRVM5ApvDRv8Gg6M7FdjNY1gL0ooCwKYNJOgZSKT 7BmTdgCvxrfpGOjvAKGHAZXYAbYZNaBq1iacXHZjMEXA3G4BsPb+ZNzWru3OjOZXI1eF V40BXFxfyTlMsF0drt+QvMnhenPNmYC/5Wl8C+dwWpvcMFSh0QfO7kffb0ToLMlqU0E+ jCRADk421FIgpn98T8GLBl/5ZfO7pMOil/arMPunAuliK3+kd6JGwnV3P4Z5ymHkTe/r SOng== 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=VW0s/cL83sVb/VJkVY7uOBauWc70nXDsRlzHKrm4POU=; b=JrMVvhlWA0rbeizQOuJCcd3SZ3b9pUVSVRVbqqHn5nrfGNY5QTyT1CvKLABnzEcPO0 yIidgWH42FImxonm3lho2IZ5li6/sxCIMcZiIo+cJ/OUjm8YggIOE9xr+r6Jk+lS8w9p kGODqEeY3iONSzx0/uL3MVLRKVvvBrl7+sD1IFdzXru8ZjTJ4URCwqCnqFkNLRVmyTvl d7fwrC8GfbvcdY/2OVSLXbBJQyyr3pIMkpF22UIvWUAY8B/FReLgxKoakGBDNTfg+IHN V6FcTgM24MOniPdoHM/4PhEIspFUPAJj39JzMU3fKel8OyQcvqcDc1z+1mpu2+fmhyZP Bq+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1IkYUjis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i62-20020a638741000000b003fcc8ec5d62si9872710pge.275.2022.06.13.09.16.08; Mon, 13 Jun 2022 09:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1IkYUjis; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S243702AbiFMKqh (ORCPT + 99 others); Mon, 13 Jun 2022 06:46:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345424AbiFMKn2 (ORCPT ); Mon, 13 Jun 2022 06:43:28 -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 F1E55BF7F; Mon, 13 Jun 2022 03:24:34 -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 B740DB80E2D; Mon, 13 Jun 2022 10:24:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28BB2C34114; Mon, 13 Jun 2022 10:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115872; bh=Cut0+u9MP6b/Kmq7XAq3+08UFXZ4+zwHC1ec9kPwMOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1IkYUjisaeCJvdMcVZCia1IeSOyF5G6Hi0gRjGSjAH7IvPXv5GPIOmYUlL3pFaj0g Hgfi73AfTkJhiZ2NAkr85UiRR1kSJ0Ng33pQ+5a3xer23yr4qj1zUkKZoC/cXJAtvF CMziDjPVoPRx2f5yqp+pUMLTEf+wrFu9FTq8ohqk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Heiko Stuebner , Sasha Levin Subject: [PATCH 4.14 064/218] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() Date: Mon, 13 Jun 2022 12:08:42 +0200 Message-Id: <20220613094921.765166142@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Yang Yingliang [ Upstream commit f8c242908ad15bbd604d3bcb54961b7d454c43f8 ] It will cause null-ptr-deref in resource_size(), if platform_get_resource() returns NULL, move calling resource_size() after devm_ioremap_resource() that will check 'res' to avoid null-ptr-deref. Fixes: 2048e3286f34 ("drm: rockchip: Add basic drm driver") Signed-off-by: Yang Yingliang Signed-off-by: Heiko Stuebner Link: https://patchwork.freedesktop.org/patch/msgid/20220422032854.2995175-1-yangyingliang@huawei.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 7010424b2f89..80a65eaed0be 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1551,10 +1551,10 @@ static int vop_bind(struct device *dev, struct device *master, void *data) vop_win_init(vop); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - vop->len = resource_size(res); vop->regs = devm_ioremap_resource(dev, res); if (IS_ERR(vop->regs)) return PTR_ERR(vop->regs); + vop->len = resource_size(res); vop->regsbak = devm_kzalloc(dev, vop->len, GFP_KERNEL); if (!vop->regsbak) -- 2.35.1