Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4926445rwb; Sun, 13 Nov 2022 17:21:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FokDJ0tdSsilKLMSiMx9Qjy//8E6cMMXhFN3TJcoYOoGN11sUbtIFtdy5T8QP5jl8nGxR X-Received: by 2002:a05:6402:148c:b0:458:d7b5:9793 with SMTP id e12-20020a056402148c00b00458d7b59793mr9260138edv.377.1668388907687; Sun, 13 Nov 2022 17:21:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668388907; cv=none; d=google.com; s=arc-20160816; b=OPI6Oyk/PhVjPtA/j1RtVq9w2Lqho7QfFOhYefuq4dG81nDXkwWqKsTsSsMzwJLhtw jlkEVLP99nFlsF4LTJhXKCodawiIczUs7KNuZ18hEyfhBo8BIYFWhpRoTQzs5Rz0LZbS j5f1Q9vLk/o3WTNbWQLcjSCLizkUDueRQqqXTslOnkgPd1DTLvnPX86eFVgYCn60RqeQ PqPtmBd4Icf6kq+L9/BC3RKbLn/KWGe/tK3Irl/wEund33ovjh0B/f6aF1xU6QVFYHN6 8L1tCanUyN8y5CgcxK81z8QAyX8A2UCk4VN7L0gZRwHs4znKoyDYsmDnvl7yebOv5JwW WewA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=F7BWZph/vKB+o1GELxMH06QD7mg4e7wLkNCDQCX4yso=; b=jsvF6CjxlvdnHmiEtkkwgQEgtCFpicH0nw18/N5K/wVQlxM7jTMgEHcTkAyjkOxNCA YacnPEp6ZCvLcgyubxqjCZUr541CLOuO5Il9xYtEa20ofGFO2/wHjfAsyZ+U5dAnXvas GJvkqI18y3joihIeKRhjU0iSCRymgYPeaW8KnCT7vdBKW/BCEpPyLr7tyjmdSmyxXkFV HSOvL8ML4G1BKNZD4OAKH6ePaXWvH4nQ9ZzGGxhmNcEfM5aofzjRi49WYIF6kXL7/DG/ K1a/iaGnxlsW2ppmIRXd7s7trK70LBZdzM6Q85tmk+1ir5mUAuPFdNw7E0rHOteHFo+S iiGQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q26-20020a50cc9a000000b0045c3f6adb7csi7464950edi.215.2022.11.13.17.21.24; Sun, 13 Nov 2022 17:21:47 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235495AbiKNAxP (ORCPT + 89 others); Sun, 13 Nov 2022 19:53:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233069AbiKNAxO (ORCPT ); Sun, 13 Nov 2022 19:53:14 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20F80DE9D for ; Sun, 13 Nov 2022 16:53:13 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N9W4V51l4zHvqK; Mon, 14 Nov 2022 08:52:42 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 08:53:11 +0800 Received: from ubuntu1804.huawei.com (10.67.175.30) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 14 Nov 2022 08:53:10 +0800 From: Hui Tang To: , , CC: , , Subject: [PATCH] reset: uniphier-glue: Fix possible null-ptr-deref Date: Mon, 14 Nov 2022 08:49:58 +0800 Message-ID: <20221114004958.258513-1-tanghui20@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.30] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 It will cause null-ptr-deref when resource_size(res) invoked, if platform_get_resource() returns NULL. Fixes: 499fef09a323 ("reset: uniphier: add USB3 core reset control") Signed-off-by: Hui Tang --- drivers/reset/reset-uniphier-glue.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/reset/reset-uniphier-glue.c b/drivers/reset/reset-uniphier-glue.c index 146fd5d45e99..15abac9fc72c 100644 --- a/drivers/reset/reset-uniphier-glue.c +++ b/drivers/reset/reset-uniphier-glue.c @@ -47,7 +47,6 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct uniphier_glue_reset_priv *priv; struct resource *res; - resource_size_t size; int i, ret; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -60,7 +59,6 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev) return -EINVAL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - size = resource_size(res); priv->rdata.membase = devm_ioremap_resource(dev, res); if (IS_ERR(priv->rdata.membase)) return PTR_ERR(priv->rdata.membase); @@ -96,7 +94,7 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev) spin_lock_init(&priv->rdata.lock); priv->rdata.rcdev.owner = THIS_MODULE; - priv->rdata.rcdev.nr_resets = size * BITS_PER_BYTE; + priv->rdata.rcdev.nr_resets = resource_size(res) * BITS_PER_BYTE; priv->rdata.rcdev.ops = &reset_simple_ops; priv->rdata.rcdev.of_node = dev->of_node; priv->rdata.active_low = true; -- 2.17.1