Skip to contentSkip to conversation

hid: picolcd: testing the wrong variable

PATCH In review Dan Carpenter 3 participants 4 messages Aug 6, 2010

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

PATCH 1/1 hid: picolcd: testing the wrong variable

"ref_cnt" is a point to the reference count and it's non-null. We really want to test the reference count itself.

drivers/hid/hid-picolcd.c +1 -1
index 346f0e3..c0bdeba 100644
@@ -547,7 +547,7 @@ static void picolcd_fb_destroy(struct fb_info *info)
 	ref_cnt--;
 	mutex_lock(&info->lock);
 	(*ref_cnt)--;
-	may_release = !ref_cnt;
+	may_release = !*ref_cnt;
 	mutex_unlock(&info->lock);
 	if (may_release) {
 		framebuffer_release(info);
maintainer
#1 lore raw

Thanks for spotting!

But while fixing this one also fix the ordering (which was never reached due to this wrong check) a few lines later.

Patch (combined) at the end.

Thanks,
Bruno

Quoted 10 lines · On Fri, 6 Aug 2010 08:28:49 Dan Carpenter <[email protected]> wrote:

"ref_cnt" is a point to the reference count and it's non-null. We really want to test the reference count itself.

drivers/hid/hid-picolcd.c +0 -0
index 346f0e3..c0bdeba 100644

drivers/hid/hid-picolcd.c static void picolcd_fb_destroy(struct fb_info *info) · line 553

Quoted 8 lines
drivers/hid/hid-picolcd.c +1 -1
@@ -547,7 +547,7 @@ static void picolcd_fb_destroy(struct fb_info *info)
 	ref_cnt--;
 	mutex_lock(&info->lock);
 	(*ref_cnt)--;
-	may_release = !ref_cnt;
+	may_release = !*ref_cnt;
 	mutex_unlock(&info->lock);
 	if (may_release) {
 		framebuffer_release(info);
drivers/hid/hid-picolcd.c +2 -2
@@ -547,11 +547,11 @@ static void picolcd_fb_destroy(struct fb
 	ref_cnt--;
 	mutex_lock(&info->lock);
 	(*ref_cnt)--;
-	may_release = !ref_cnt;
+	may_release = !*ref_cnt;
 	mutex_unlock(&info->lock);
 	if (may_release) {
-		framebuffer_release(info);
 		vfree((u8 *)info->fix.smem_start);
+		framebuffer_release(info);
 	}
 }
 
#2 lore raw
Quoted 36 lines · Bruno Prémont

Thanks for spotting!

But while fixing this one also fix the ordering (which was never reached due to this wrong check) a few lines later.

Patch (combined) at the end.

Thanks,
Bruno

Quoted 18 lines · On Fri, 6 Aug 2010 08:28:49 Dan Carpenter <[email protected]> wrote:

"ref_cnt" is a point to the reference count and it's non-null. We really want to test the reference count itself.

drivers/hid/hid-picolcd.c +1 -1
index 346f0e3..c0bdeba 100644
@@ -547,7 +547,7 @@ static void picolcd_fb_destroy(struct fb_info *info)
 	ref_cnt--;
 	mutex_lock(&info->lock);
 	(*ref_cnt)--;
-	may_release = !ref_cnt;
+	may_release = !*ref_cnt;
 	mutex_unlock(&info->lock);
 	if (may_release) {
 		framebuffer_release(info);
drivers/hid/hid-picolcd.c +0 -0
@@ -547,11 +547,11 @@ static void picolcd_fb_destroy(struct fb
 	ref_cnt--;
 	mutex_lock(&info->lock);

drivers/hid/hid-picolcd.c static void picolcd_fb_destroy(struct fb · line 556

Quoted 10 lines
drivers/hid/hid-picolcd.c +2 -2
 	(*ref_cnt)--;
-	may_release = !ref_cnt;
+	may_release = !*ref_cnt;
 	mutex_unlock(&info->lock);
 	if (may_release) {
-		framebuffer_release(info);
 		vfree((u8 *)info->fix.smem_start);
+		framebuffer_release(info);
 	}
 }

I have applied the patch fixing the ordering, along with adding

to it. Please shoud if that is not proper.

Thanks,

Signature · 6 lines
Jiri Kosina
SUSE Labs, Novell Inc.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to Dan Carpenter
Quoted 10 lines · Dan Carpenter

"ref_cnt" is a point to the reference count and it's non-null. We really want to test the reference count itself.

drivers/hid/hid-picolcd.c +0 -0
index 346f0e3..c0bdeba 100644

drivers/hid/hid-picolcd.c static void picolcd_fb_destroy(struct fb_info *info) · line 553

Quoted 8 lines
drivers/hid/hid-picolcd.c +1 -1
@@ -547,7 +547,7 @@ static void picolcd_fb_destroy(struct fb_info *info)
 	ref_cnt--;
 	mutex_lock(&info->lock);
 	(*ref_cnt)--;
-	may_release = !ref_cnt;
+	may_release = !*ref_cnt;
 	mutex_unlock(&info->lock);
 	if (may_release) {
 		framebuffer_release(info);

Thanks a lot for spotting this. Applied.

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.