Skip to contentSkip to conversation

watchdog: fix clk_get() error check

PATCH In review Akinobu Mita 3 participants 4 messages Dec 19, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: fix clk_get() error check

The return value of clk_get() should be checked by IS_ERR().

Cc Wim Van Sebroeck <[email protected]>
---
 drivers/char/watchdog/pnx4008_wdt.c |    3 ++-
 drivers/char/watchdog/s3c2410_wdt.c |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/char/watchdog/pnx4008_wdt.c +2 -1
Index: 2.6-mm/drivers/char/watchdog/pnx4008_wdt.c
===================================================================
@@ -283,7 +283,8 @@ static int pnx4008_wdt_probe(struct plat
 	wdt_base = (void __iomem *)IO_ADDRESS(res->start);
 
 	wdt_clk = clk_get(&pdev->dev, "wdt_ck");
-	if (!wdt_clk) {
+	if (IS_ERR(wdt_clk)) {
+		ret = PTR_ERR(wdt_clk);
 		release_resource(wdt_mem);
 		kfree(wdt_mem);
 		goto out;
drivers/char/watchdog/s3c2410_wdt.c +2 -2
Index: 2.6-mm/drivers/char/watchdog/s3c2410_wdt.c
===================================================================
@@ -392,10 +392,10 @@ static int s3c2410wdt_probe(struct platf
 	}
 
 	wdt_clock = clk_get(&pdev->dev, "watchdog");
-	if (wdt_clock == NULL) {
+	if (IS_ERR(wdt_clock)) {
 		printk(KERN_INFO PFX "failed to find watchdog clock source\n");
 		iounmap(wdt_base);
-		return -ENOENT;
+		return PTR_ERR(wdt_clock);
 	}
 
 	clk_enable(wdt_clock);
#1 lore raw
Quoted 1 line · Akinobu Mita

The return value of clk_get() should be checked by IS_ERR().

thanks for spotting this, but this will probably clash with a cleanup patch I sent a day or two ago to streamline the exit path in the driver.

see http://lkml.org/lkml/2006/12/18/65

Signature · 4 lines
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#2 lore raw

Hi Ben,

Quoted 8 lines · Akinobu Mita
Quoted 1 line

The return value of clk_get() should be checked by IS_ERR().

thanks for spotting this, but this will probably clash with a cleanup patch I sent a day or two ago to streamline the exit path in the driver.

see http://lkml.org/lkml/2006/12/18/65

It did, but I modified it slightly so that it worked with your previous patch also. Can you test below patch?

Thanks,
Wim.

drivers/char/watchdog/s3c2410_wdt.c +2 -2
@@ -393,9 +393,9 @@
 	}
 
 	wdt_clock = clk_get(&pdev->dev, "watchdog");
-	if (wdt_clock == NULL) {
+	if (IS_ERR(wdt_clock)) {
 		printk(KERN_INFO PFX "failed to find watchdog clock source\n");
-		ret =  -ENOENT;
+		ret = PTR_ERR(wdt_clock);
 		goto err_irq;
 	}
 
#3 lore raw
In reply to Akinobu Mita

Hi Akinobu,

Quoted 1 line

The return value of clk_get() should be checked by IS_ERR().

Modified patch added to linux-2.6-watchdog-mm git tree. (I needed to modify the s3c2410_wdt.c part since because of the changes we added yesterday).

Greetings,
Wim.