ds1wm: should check for IS_ERR(clk) instead of NULL
authorAnton Vorontsov <[email protected]>
Tue, 4 Mar 2008 22:28:43 +0000 (14:28 -0800)
committerLinus Torvalds <[email protected]>
Wed, 5 Mar 2008 00:35:12 +0000 (16:35 -0800)
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.

Signed-off-by: Anton Vorontsov <[email protected]>
Acked-by: Evgeniy Polyakov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/w1/masters/ds1wm.c

index 688e435b4d9a60cb56097ee85c82ec3b662bd479..78a14dacb8ecd9a400c74b0f6d188c723ce3c286 100644 (file)
@@ -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;
        }