clk: lmk04832: fix checks for allocation failure
Subsystems (2)
PATCH 1/1 clk: lmk04832: fix checks for allocation failure
The devm_kcalloc() function returns NULL on error, it never returns error pointers so these conditions need to be fixed.
--- drivers/clk/clk-lmk04832.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/clk-lmk04832.c +6 -6
@@ -1425,23 +1425,23 @@ static int lmk04832_probe(struct spi_device *spi) lmk->dclk =devm_kcalloc (lmk->dev, info->num_channels >>1 ,sizeof (struct lmk_dclk ),GFP_KERNEL ); -if (IS_ERR (lmk->dclk)) { - ret =PTR_ERR (lmk->dclk); +if (!lmk->dclk) { + ret = -ENOMEM ; goto err_disable_oscin; } lmk->clkout =devm_kcalloc (lmk->dev, info->num_channels,sizeof (*lmk->clkout),GFP_KERNEL ); -if (IS_ERR (lmk->clkout)) { - ret =PTR_ERR (lmk->clkout); +if (!lmk->clkout) { + ret = -ENOMEM ; goto err_disable_oscin; } lmk->clk_data =devm_kzalloc (lmk->dev,struct_size (lmk->clk_data, hws, info->num_channels),GFP_KERNEL ); -if (IS_ERR (lmk->clk_data)) { - ret =PTR_ERR (lmk->clk_data); +if (!lmk->clk_data) { + ret = -ENOMEM ; goto err_disable_oscin; }
Signature · 1 line
2.30.2
Hi Dan,
Quoted 9 lines
-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: June 30, 2021 9:50 AM
To: Michael Turquette <[email protected]>; Liam Beguin <[email protected]>
Cc: Stephen Boyd <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH] clk: lmk04832: fix checks for allocation failure
Quoted 5 lines
The
devm_kcalloc()function returns NULL on error, it never returns error pointers so these conditions need to be fixed.Fixes 3bc61cfd6f4a ("clk: add support for the lmk04832")Signed-off-by Dan Carpenter <[email protected]>
A similar patch was posted earlier yesterday. See [1]
[1] https://patchwork.kernel.org/project/linux-clk/patch/[email protected]/
Liam
Quoted 43 lines
--- drivers/clk/clk-lmk04832.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/clk/clk-lmk04832.c +6
-6@@ -1425,23 +1425,23 @@ static int lmk04832_probe(struct spi_device *spi) lmk->dclk =devm_kcalloc (lmk->dev, info->num_channels >>1 ,sizeof (struct lmk_dclk ),GFP_KERNEL ); -if (IS_ERR (lmk->dclk)) { - ret =PTR_ERR (lmk->dclk); +if (!lmk->dclk) { + ret = -ENOMEM ; goto err_disable_oscin; } lmk->clkout =devm_kcalloc (lmk->dev, info->num_channels,sizeof (*lmk->clkout),GFP_KERNEL ); -if (IS_ERR (lmk->clkout)) { - ret =PTR_ERR (lmk->clkout); +if (!lmk->clkout) { + ret = -ENOMEM ; goto err_disable_oscin; } lmk->clk_data =devm_kzalloc (lmk->dev,struct_size (lmk->clk_data, hws, info- >num_channels),GFP_KERNEL ); -if (IS_ERR (lmk->clk_data)) { - ret =PTR_ERR (lmk->clk_data); +if (!lmk->clk_data) { + ret = -ENOMEM ;drivers/clk/clk-lmk04832.c +0
-1goto err_disable_oscin; } --2.30.2