diff mbox

powerpc/mpc5121: fix NULL test

Message ID 4960EF54.1090907@gmail.com (mailing list archive)
State Accepted, archived
Commit 23faf63123e306b4a134f6d6c501813f6c8599dc
Delegated to: Grant Likely
Headers show

Commit Message

roel kluin Jan. 4, 2009, 5:18 p.m. UTC
strcmp on NULL results in a segmentation fault, also, remove the second,
redundant test on dev

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Please verify whether this patch correct.
diff mbox

Patch

diff --git a/arch/powerpc/platforms/512x/clock.c b/arch/powerpc/platforms/512x/clock.c
index f416014..1bcff94 100644
--- a/arch/powerpc/platforms/512x/clock.c
+++ b/arch/powerpc/platforms/512x/clock.c
@@ -56,12 +56,12 @@  static struct clk *mpc5121_clk_get(struct device *dev, const char *id)
 	int dev_match = 0;
 	int id_match = 0;
 
-	if (dev == NULL && id == NULL)
+	if (dev == NULL || id == NULL)
 		return NULL;
 
 	mutex_lock(&clocks_mutex);
 	list_for_each_entry(p, &clocks, node) {
-		if (dev && dev == p->dev)
+		if (dev == p->dev)
 			dev_match++;
 		if (strcmp(id, p->name) == 0)
 			id_match++;