Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2175387iof; Tue, 7 Jun 2022 22:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw25E2DAl/Uow8HtcwXvqvkPgXql8pB9yaA3hZwxbOKrfXa2RKDKlOrSC+KhCipmaDaCl/F X-Received: by 2002:a62:7c14:0:b0:51b:9d03:a4c7 with SMTP id x20-20020a627c14000000b0051b9d03a4c7mr32553852pfc.74.1654665192152; Tue, 07 Jun 2022 22:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665192; cv=none; d=google.com; s=arc-20160816; b=Osw/A0e6hUnRvoK//Y9+sTLkH2zMsn2eyCOa79YJ/JjUb+6yuweexyNDe+yVabw97X pQ/uqOrPT6UqK5E7vR5sEIYajCudAjWUR8b5KrTwxFJ/zEh9o6ak1fyxnncLyeSdA6Mp pjHl7LMQke6T/EHJVpSlpS7wWCZYBufLLuAtc0zQZU7Xvd0+o5nCU4zwsHwLj9cUwPg5 5g+RHpwDl9pFTqjf7DHXLckdDGfDD0qyj+81LD5UbFiPtCM3BAWiM+vHg32FsWB9nvno Mlg8l+mmwH25hYfrPGiyHBE312QdR48qqqdFR9h65GWIbXGL9S4mbX4rHLomw5vAlJ9D iaSg== 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=YTPGW8SfZYZaNWqOGjjlpBP/Exyq1ITnyQ01jp2Q8ME=; b=ODiBQZ4Rd5Q3pH57NGZEcA2oGQPyVBtipxj4RWcyngihxiEcOaCNb3hZv0cmmBu9I7 JQRi808Jv2tnJXm3rcujgOlorvE+zWjuEIo4Fzos3Y8pOvLHdHUj/mWTZVtrktX9vy9O Ozqq9kdy/sbK6OGAJvefc17tVAfZxKCurN6fvmCAysrVm+We66KO2vNvyN/A8zbM3a+R lFq0u3S0LROohyM5UbukwXuI9wpU6r97I93NIY6aFTgO9ijfAFGt0NB09gXZhOstrvlf gYMPnb/E+e8sO8YbPhYixImbwnSUj+U0vynExWxZ96I9RlK6py0BdvN8UvZmqQPGrHk9 UR3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S+2sAHJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s64-20020a17090a2f4600b001e30a5c2fafsi39299584pjd.14.2022.06.07.22.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:13:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S+2sAHJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3D99F3A9CC8; Tue, 7 Jun 2022 21:43:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347462AbiFGRjN (ORCPT + 99 others); Tue, 7 Jun 2022 13:39:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347349AbiFGRak (ORCPT ); Tue, 7 Jun 2022 13:30:40 -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 D7AEB110984; Tue, 7 Jun 2022 10:26:24 -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 96495B8220C; Tue, 7 Jun 2022 17:26:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07694C385A5; Tue, 7 Jun 2022 17:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622782; bh=/PJHXJD5l+6VAC4skzJzuffQbUWHX6LhgWNRyk0rliw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+2sAHJT6z83xExN8GUUd0nYc1Y3tRkEDCvvctRl05DrsAN1MQEPcVevcvY6DFlDG TIVZP52T3vJjiw3V3T5AmTuJZQJMNJkrnVJ9HiLXa0O98zznMxIaPZJdrHhlVP774v /sMCjqi34q827pTGP4tzXB4holwYcu0i+0k+IImI= 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 5.10 181/452] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() Date: Tue, 7 Jun 2022 19:00:38 +0200 Message-Id: <20220607164913.956128333@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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: 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 0f23144491e4..91568f166a8a 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -2097,10 +2097,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); res = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (res) { -- 2.35.1