Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2127089iof; Tue, 7 Jun 2022 20:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQCZHoo30KMRrtOaVBtsEYjbTbX/68liOaERbwtGhN3WqKbsp49FJG78Daj+/uDYOv2/Zx X-Received: by 2002:a17:902:e78f:b0:163:7572:f83f with SMTP id cp15-20020a170902e78f00b001637572f83fmr32852889plb.60.1654659501808; Tue, 07 Jun 2022 20:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654659501; cv=none; d=google.com; s=arc-20160816; b=yvazFVy0hUonbZx0BRyxi+ZtMs/ofMZlcKRn1u36cVeYoac4GdJYMCi6XSdO0flmnt vxZNuGMkLCTyxZUO7HtWd3W0RSsYldpUeMa/piFMkhpCvXfhDdM27b7XL+XGApjfoGr0 8JuL0pvsfgW9hkpmI6xwU6I8BSI17QqeJsZmmYX/Deefz/FH1DqgQM6GfN9fOJyTVltS 6HBfkCgW0nztZZ5SHXDvAMIi6NjHRLJS20YsFdynhsLLFyO6YrwbQ5HnVikb0Oqyc9C8 9oMf6SaMH+ApCkGydKPiVTFnP5d9YPbkkkTTs6XrvRuMVD1X7vqAsY780JOcbpXJFZg/ dM9Q== 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=PVEcFPCalbogga/iFfUbnGo2zoODBWJKT0dMhwxibeM=; b=ZJL/45rk7QBSSbzvoSAwcmPhaGtmV+R0kGiLo9cn70WV1BFN5OxhCEWf3NhvEm1SuU cRWsVfosPXARnuCzZbum5eENSZhPx7zfCpQIaf16irCZrQ065l7HGN9ZfUpY7kr5PNdQ tWMajH/KpH3HjnL36BZFrf5zLgHXEojBUHTvHIksZgt+lgHI/n5nEniWDyELnTlWOIcS ryqQwcnSzNn5D4dzVlKbfa6T1SEdOWNfmLnR2zSbqMDreaozYQZQlOxO6YLU88AROalg Xhr/5sQvIXTKzn1XWr1XL9NO7SlJNnbLSgO1lXchJ8MBz/S0yKP0oxqYjX0qf0Noiy8F YfXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W71qUd7J; 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 c8-20020a6566c8000000b003f25a28a4afsi27990753pgw.241.2022.06.07.20.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:38:21 -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=W71qUd7J; 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 A4D341E3B27; Tue, 7 Jun 2022 19:56:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385755AbiFGWmE (ORCPT + 99 others); Tue, 7 Jun 2022 18:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380533AbiFGVa5 (ORCPT ); Tue, 7 Jun 2022 17:30:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38C4152DBA; Tue, 7 Jun 2022 12:03:00 -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 39182B822C0; Tue, 7 Jun 2022 19:02:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9643AC385A2; Tue, 7 Jun 2022 19:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628578; bh=w3e8wwqSf2IJK2TlKn/ftOI+LXVaqh+1NGePEZ9+3fM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W71qUd7JWPrYF0YtnlV2ce4o8a6MlDXc3jD9KCuCzNgwQoyiXARx2AaKmVgmgMbxP 4eJ6DkHeOm1GGMHW35c/lxAVW9glsZVeby49Sbuxk8oAImCKEMOZM6IMw+hnMSRvNc rvP5ad8xuMI/1NlPQU1DklpA9KY3sMRHtxgwz/Sc= 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.18 381/879] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() Date: Tue, 7 Jun 2022 18:58:19 +0200 Message-Id: <20220607165013.927700716@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 3e8d9e2d1b67..d53037531f40 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -2118,10 +2118,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