From patchwork Wed May 18 02:08:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12853066 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EF0FC433EF for ; Wed, 18 May 2022 01:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234143AbiERB5K (ORCPT ); Tue, 17 May 2022 21:57:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234054AbiERB47 (ORCPT ); Tue, 17 May 2022 21:56:59 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5166030579; Tue, 17 May 2022 18:56:56 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4L2wyJ2fvlzGppJ; Wed, 18 May 2022 09:54:00 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 18 May 2022 09:56:54 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 18 May 2022 09:56:54 +0800 From: Yang Yingliang To: , CC: , , , , Subject: [PATCH -next v2] net: ethernet: sunplus: add missing of_node_put() in spl2sw_mdio_init() Date: Wed, 18 May 2022 10:08:12 +0800 Message-ID: <20220518020812.2626293-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org of_get_child_by_name() returns device node pointer with refcount incremented. The refcount should be decremented before returning from spl2sw_mdio_init(). Fixes: fd3040b9394c ("net: ethernet: Add driver for Sunplus SP7021") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Reviewed-by: Wells Lu --- v2: add fix tag. --- drivers/net/ethernet/sunplus/spl2sw_mdio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/sunplus/spl2sw_mdio.c b/drivers/net/ethernet/sunplus/spl2sw_mdio.c index 139ac8f2685e..733ae1704269 100644 --- a/drivers/net/ethernet/sunplus/spl2sw_mdio.c +++ b/drivers/net/ethernet/sunplus/spl2sw_mdio.c @@ -97,8 +97,10 @@ u32 spl2sw_mdio_init(struct spl2sw_common *comm) /* Allocate and register mdio bus. */ mii_bus = devm_mdiobus_alloc(&comm->pdev->dev); - if (!mii_bus) - return -ENOMEM; + if (!mii_bus) { + ret = -ENOMEM; + goto out; + } mii_bus->name = "sunplus_mii_bus"; mii_bus->parent = &comm->pdev->dev; @@ -110,10 +112,13 @@ u32 spl2sw_mdio_init(struct spl2sw_common *comm) ret = of_mdiobus_register(mii_bus, mdio_np); if (ret) { dev_err(&comm->pdev->dev, "Failed to register mdiobus!\n"); - return ret; + goto out; } comm->mii_bus = mii_bus; + +out: + of_node_put(mdio_np); return ret; }