can: m_can: Add check for devm_clk_get
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Wed, 23 Nov 2022 06:36:51 +0000 (14:36 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Dec 2022 10:28:40 +0000 (11:28 +0100)
[ Upstream commit 68b4f9e0bdd0f920d7303d07bfe226cd0976961d ]

Since the devm_clk_get may return error,
it should be better to add check for the cdev->hclk,
as same as cdev->cclk.

Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/all/20221123063651.26199-1-jiasheng@iscas.ac.cn
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/can/m_can/m_can.c

index c4596fb..46ab615 100644 (file)
@@ -1931,7 +1931,7 @@ int m_can_class_get_clocks(struct m_can_classdev *cdev)
        cdev->hclk = devm_clk_get(cdev->dev, "hclk");
        cdev->cclk = devm_clk_get(cdev->dev, "cclk");
 
-       if (IS_ERR(cdev->cclk)) {
+       if (IS_ERR(cdev->hclk) || IS_ERR(cdev->cclk)) {
                dev_err(cdev->dev, "no clock found\n");
                ret = -ENODEV;
        }