Skip to contentSkip to conversation

clk: lmk04832: fix return value check in lmk04832_probe()

PATCH Applied Wang Hai 3 participants 3 messages Jun 30, 2021 Common clk

lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 clk: lmk04832: fix return value check in lmk04832_probe()

In case of error, the function devm_kzalloc() and devm_kcalloc() return NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 3bc61cfd6f4a ("clk: add support for the lmk04832")
---
 drivers/clk/clk-lmk04832.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/clk-lmk04832.c +6 -6
index 0cd76e626c3..66ad5cbe702 100644
@@ -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.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Wang Hai <[email protected]>
Sent: June 29, 2021 10:03 PM
To: [email protected]; [email protected]; Liam Beguin <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH -next] clk: lmk04832: fix return value check in lmk04832_probe()

Quoted 7 lines

In case of error, the function devm_kzalloc() and devm_kcalloc() return NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 3bc61cfd6f4a ("clk: add support for the lmk04832")
Quoted 43 lines
---
 drivers/clk/clk-lmk04832.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/clk-lmk04832.c +6 -6
index 0cd76e626c3..66ad5cbe702 100644
@@ -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 -1
 		goto err_disable_oscin;
 	}
 
--

2.17.1