From patchwork Wed Jul 26 17:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanjun Gong X-Patchwork-Id: 13328390 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C0AB1AA65 for ; Wed, 26 Jul 2023 17:06:00 +0000 (UTC) Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CCFC5E7E for ; Wed, 26 Jul 2023 10:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=CBOLseeOvhn/zIvU7B +z8LlBbXJbPz+dEvWGijxih8c=; b=owe2geTunxmC5f1/4Zk5xkP5S0k4LGOTxM 2AeoyvkvvuIx7ETEl71o/B9UVooI8P1U9e2sIpUJTyteeBHZcC3Vd9MmS7SIyxxU Ehh34YHXKgl2F+COqOMx+x4z59tqzMxi2J+cYaRxhW1rZm72bpyI8oA8/9ffsJWN RjdGaSUT4= Received: from localhost.localdomain (unknown [202.112.113.212]) by zwqz-smtp-mta-g3-0 (Coremail) with SMTP id _____wDH58dEUsFkgkhiBQ--.17057S4; Thu, 27 Jul 2023 01:05:13 +0800 (CST) From: Yuanjun Gong To: Florian Fainelli , Andrew Lunn , Vladimir Oltean , "David S . Miller" , netdev@vger.kernel.org Cc: Yuanjun Gong Subject: [PATCH 1/1] net: dsa: fix value check in bcm_sf2_sw_probe() Date: Thu, 27 Jul 2023 01:05:06 +0800 Message-Id: <20230726170506.16547-1-ruc_gongyuanjun@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: _____wDH58dEUsFkgkhiBQ--.17057S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7Jr4rAw4fGw18Kw4xAFyDtrb_yoWkKFgEkw 43JFZ3Xr13XrZYyryDGw4rXrZFkFWkArnaqrWvy3yYyr9rX3WDXrWkXr17A3yUWws7AFy0 yF17Za4fCa4rAjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRNhL07UUUUU== X-Originating-IP: [202.112.113.212] X-CM-SenderInfo: 5uxfsw5rqj53pdqm30i6rwjhhfrp/1tbiUQq45WDESb3qpgAAsa X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L4,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 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-Patchwork-Delegate: kuba@kernel.org in bcm_sf2_sw_probe(), check the return value of clk_prepare_enable() and return the error code if clk_prepare_enable() returns an unexpected value. Fixes: e9ec5c3bd238 ("net: dsa: bcm_sf2: request and handle clocks") Signed-off-by: Yuanjun Gong Reviewed-by: Florian Fainelli --- drivers/net/dsa/bcm_sf2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c index cde253d27bd0..72374b066f64 100644 --- a/drivers/net/dsa/bcm_sf2.c +++ b/drivers/net/dsa/bcm_sf2.c @@ -1436,7 +1436,9 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev) if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); - clk_prepare_enable(priv->clk); + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; priv->clk_mdiv = devm_clk_get_optional(&pdev->dev, "sw_switch_mdiv"); if (IS_ERR(priv->clk_mdiv)) { @@ -1444,7 +1446,9 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev) goto out_clk; } - clk_prepare_enable(priv->clk_mdiv); + ret = clk_prepare_enable(priv->clk_mdiv); + if (ret) + goto out_clk; ret = bcm_sf2_sw_rst(priv); if (ret) {