Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp442564iog; Mon, 13 Jun 2022 06:06:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfI7xsSmy7yhPm50A4Jervy6aVU25dq33SeaWPXDWYLcfaTm+OIiztTuTvjtNOVHCs7EFz X-Received: by 2002:a17:903:187:b0:166:4360:a4fa with SMTP id z7-20020a170903018700b001664360a4famr56418256plg.87.1655125560489; Mon, 13 Jun 2022 06:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125560; cv=none; d=google.com; s=arc-20160816; b=UZ8GVoVo7lPIFTv3PsOIrViTjIeVL8piYgBFcgIBsl1qZnzLBsKITlTEBQ4d3/zF1T 507PoKWIwYPANTZ+b1bNUQEn52ogo6Ad++e9STHJpOy5HF3/XtvYRdM0HqlIRcwSu7ZA StPgNaRAj1tE7XDxv7wohPkl2pvhalKyUhTfNz53ckEH09osSPLOerkuzHZieHUebQQo x/APrJjDaYkghoXY7dStNXznM2Jqhut2v3EnT/KErwaYhXEiHZwPa6l+u9jJYL17uY9W veINM3ZLcMFk0xjeM4ER6KHW6MuVgqEESvot21cdBB7En6vtaWDEBYNrxkP6+YGivs10 QAoQ== 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=MBg6KMHJFTrnV4NG/P+0rCNfhQMj/uhX71wRNoCoDx4=; b=Yyi0Z8pvm789umX0KLSIobjYDE8j4ZAuhgNKxsC1sKOwplY8D2dbi2W+Zw1ipc7Z6O QIoyk/59sEzhovPfLNie8a9EIyJSPdCvvcRddJX8D9F3wVEsIZ0OFPwwQbsF9CXm92Lv ydmB+u3whRHIHcJQ/9vnfcE3giK9pRFbvcIeMCXIJS9BU0sfw8/mEFRlesiOh3gn/SY4 Ne0Y5+Uex9yds9CfZtmARGe5Y9BeChxgNMMxLsmXkhzWu7GZdz/CqFLKm6AO3jL91BIa u0Ojm4SLFFivfDncreJ3+PqkmBFesagPPQV0gPn+tF6O1w0LCWKwg+I5iJvXnjG43NIw D7XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=goIvO0zV; 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 x126-20020a626384000000b0051b9771d617si8825747pfb.179.2022.06.13.06.05.39; Mon, 13 Jun 2022 06:06:00 -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=goIvO0zV; 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 S236138AbiFMKTf (ORCPT + 99 others); Mon, 13 Jun 2022 06:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242509AbiFMKSW (ORCPT ); Mon, 13 Jun 2022 06:18:22 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2195920BC6; Mon, 13 Jun 2022 03:16:12 -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 sin.source.kernel.org (Postfix) with ESMTPS id 6E379CE110D; Mon, 13 Jun 2022 10:16:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55EDAC34114; Mon, 13 Jun 2022 10:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115368; bh=p7du8vzhJexxq60p15CXrqmwEkWIhGGbk5mD8cJHH/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goIvO0zV2M0g8OjL5Gc3I5reEBPrPG5WBMJsRkZe7MCppJWWmUIERtDGtao9K8Y2b KxuV24MngXWHuE1nB2vxiPNOI99PVca4iQWf+BAsaM8xN4EwIwZXgQ4yRwOWAl+qCw zXTYhr4uqcdw8+rff6ypK+ykWVTAzH6BM/MjgbGQ= 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.9 049/167] drm/rockchip: vop: fix possible null-ptr-deref in vop_bind() Date: Mon, 13 Jun 2022 12:08:43 +0200 Message-Id: <20220613094852.476636780@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 5bed63eee5f0..050f9a59ed54 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1524,10 +1524,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