Skip to contentSkip to conversation

ds1wm: should check for IS_ERR(clk) instead of NULL

PATCH In review Anton Vorontsov 2 participants 2 messages Feb 25, 2008 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ds1wm: should check for IS_ERR(clk) instead of NULL

On the error condition clk_get() returns ERR_PTR(..), so checking for NULL doesn't work. ds1wm module causes a kernel oops when ds1wm clock isn't registered.

This patch converts NULL check to IS_ERR(), plus uses PTR_ERR() for the return code.

---
 drivers/w1/masters/ds1wm.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/w1/masters/ds1wm.c +3 -2
index 688e435..78a14da 100644
@@ -17,6 +17,7 @@
 #include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/ds1wm.h>
 
@@ -374,8 +375,8 @@ static int ds1wm_probe(struct platform_device *pdev)
 		goto err1;
 
 	ds1wm_data->clk = clk_get(&pdev->dev, "ds1wm");
-	if (!ds1wm_data->clk) {
-		ret = -ENOENT;
+	if (IS_ERR(ds1wm_data->clk)) {
+		ret = PTR_ERR(ds1wm_data->clk);
 		goto err2;
 	}
 
Signature · 1 line
1.5.4.3
#1 lore raw

Hi Anton.

Quoted 8 lines · Anton Vorontsov

On the error condition clk_get() returns ERR_PTR(..), so checking for NULL doesn't work. ds1wm module causes a kernel oops when ds1wm clock isn't registered.

This patch converts NULL check to IS_ERR(), plus uses PTR_ERR() for the return code.

Both patches look good, thanks Anton.

Andrew, please merge them and add my ack if needed. Thank you.

Signature · 1 line
	Evgeniy Polyakov