Skip to contentSkip to conversation

drm/nva3: checking the wrong variable

PATCH In review Dan Carpenter 2 participants 2 messages Oct 11, 2011

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

PATCH 1/1 drm/nva3: checking the wrong variable

"id" is unsigned here and it's never less than zero. I believe the intent was to check the return value from nva3_pm_pll_offset(). Also I've changed it to pass on the -ENOENT error code from the lower levels instead of returning -EINVAL.

drivers/gpu/drm/nouveau/nva3_pm.c +2 -2
index e4b2b9e..0be517d 100644
@@ -112,8 +112,8 @@ nva3_pm_clock_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl,
 		return (ret = -ENOENT) ? NULL : ERR_PTR(ret);
 
 	off = nva3_pm_pll_offset(id);
-	if (id < 0)
-		return ERR_PTR(-EINVAL);
+	if (off < 0)
+		return ERR_PTR(off);
 
 
 	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
#1 lore raw
Quoted 4 lines · Dan Carpenter

"id" is unsigned here and it's never less than zero. I believe the intent was to check the return value from nva3_pm_pll_offset(). Also I've changed it to pass on the -ENOENT error code from the lower levels instead of returning -EINVAL.

The patch looks correct. It's worth noting though that a complete rewrite of that particular code is queued for 3.2 already.

Ben.

Quoted 18 lines
drivers/gpu/drm/nouveau/nva3_pm.c +2 -2
index e4b2b9e..0be517d 100644
@@ -112,8 +112,8 @@ nva3_pm_clock_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl,
 		return (ret == -ENOENT) ? NULL : ERR_PTR(ret);
 
 	off = nva3_pm_pll_offset(id);
-	if (id < 0)
-		return ERR_PTR(-EINVAL);
+	if (off < 0)
+		return ERR_PTR(off);
 
 
 	pll = kzalloc(sizeof(*pll), GFP_KERNEL);