net: (cpts) fix a missing check of clk_prepare
authorKangjie Lu <kjlu@umn.edu>
Wed, 26 Dec 2018 02:55:37 +0000 (20:55 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2019 14:37:49 +0000 (15:37 +0100)
[ Upstream commit 2d822f2dbab7f4c820f72eb8570aacf3f35855bd ]

clk_prepare() could fail, so let's check its status, and if it fails,
return its error code upstream.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/ti/cpts.c

index e7b76f6b4f67ef7ff53a22a14805d3386b789520..7d1281d812480945bececdfb00ffaa80e063f862 100644 (file)
@@ -567,7 +567,9 @@ struct cpts *cpts_create(struct device *dev, void __iomem *regs,
                return ERR_PTR(PTR_ERR(cpts->refclk));
        }
 
-       clk_prepare(cpts->refclk);
+       ret = clk_prepare(cpts->refclk);
+       if (ret)
+               return ERR_PTR(ret);
 
        cpts->cc.read = cpts_systim_read;
        cpts->cc.mask = CLOCKSOURCE_MASK(32);