2011-03-25 10:48:04

by Milton Miller

[permalink] [raw]
Subject: suspect code in cyasblkdev_block conversion to bdops->check_events()

> commit cafb0bfca1a73efd6d8a4a6a6a716e6134b96c24
> Author: Tejun Heo <[email protected]>
> Commit: Tejun Heo <[email protected]>
>
> staging: Convert to bdops->check_events()
>
> Convert two staging drivers - blkvsc_drv and cyasblkdev_block - from
> ->media_changed() to ->check_events(). The former always indicated
> media changed while the latter always indicated media not changed.
> Not sure what the drivers are trying to achieve but keep the original
> behavior.
>
> Signed-off-by: Tejun Heo <[email protected]>
> Acked-by: Greg Kroah-Hartman <[email protected]>
> Cc: Jens Axboe <[email protected]>
> Cc: Kay Sievers <[email protected]>
>
..
> diff --git a/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
> index e1851f0..842cd92 100644
..
> @@ -1090,6 +1090,7 @@ static int cyasblkdev_add_disks(int bus_num,
> bd->user_disk_0->first_minor = devidx << CYASBLKDEV_SHIFT;
> bd->user_disk_0->minors = 8;
> bd->user_disk_0->fops = &cyasblkdev_bdops;
> + bd->user_disk_0->events = DISK_EVENT_MEDIA_CHANGE;
> bd->user_disk_0->private_data = bd;
> bd->user_disk_0->queue = bd->queue.queue;
> bd->dbgprn_flags = DBGPRN_RD_RQ;
> @@ -1190,6 +1191,7 @@ static int cyasblkdev_add_disks(int bus_num,
> bd->user_disk_1->first_minor = (devidx + 1) << CYASBLKDEV_SHIFT;
> bd->user_disk_1->minors = 8;
> bd->user_disk_1->fops = &cyasblkdev_bdops;
> + bd->user_disk_0->events = DISK_EVENT_MEDIA_CHANGE;
> bd->user_disk_1->private_data = bd;
Date: Fri, 25 Mar 2011 04:48:01 -0600
X-Originating-IP: 71.22.127.106

The 0 on the above line triggered my suspect code pattern detector.

> bd->user_disk_1->queue = bd->queue.queue;
> bd->dbgprn_flags = DBGPRN_RD_RQ;
> @@ -1278,6 +1280,7 @@ static int cyasblkdev_add_disks(int bus_num,
> (devidx + 2) << CYASBLKDEV_SHIFT;
> bd->system_disk->minors = 8;
> bd->system_disk->fops = &cyasblkdev_bdops;
> + bd->system_disk->events = DISK_EVENT_MEDIA_CHANGE;
> bd->system_disk->private_data = bd;
> bd->system_disk->queue = bd->queue.queue;
> /* don't search for vfat

milton


2011-03-25 14:38:28

by Tejun Heo

[permalink] [raw]
Subject: [PATCH] staging: Fix bdops->check_events() misconversion in cyasblkdev_block.c

Commit cafb0bfca1 (staging: Convert to bdops->check_events())
incorrectly set bd->user_disk_0->events while initializing
bd->user_disk_1. Fix it.

The problem was spotted by Milton's suspect code pattern detector.

Signed-off-by: Tejun Heo <[email protected]>
Reported-by: Milton Miller <[email protected]>
---
Nice spotting Milton. Thank you.

drivers/staging/westbridge/astoria/block/cyasblkdev_block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
index 842cd92..289729d 100644
--- a/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
+++ b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c
@@ -1191,7 +1191,7 @@ static int cyasblkdev_add_disks(int bus_num,
bd->user_disk_1->first_minor = (devidx + 1) << CYASBLKDEV_SHIFT;
bd->user_disk_1->minors = 8;
bd->user_disk_1->fops = &cyasblkdev_bdops;
- bd->user_disk_0->events = DISK_EVENT_MEDIA_CHANGE;
+ bd->user_disk_1->events = DISK_EVENT_MEDIA_CHANGE;
bd->user_disk_1->private_data = bd;
bd->user_disk_1->queue = bd->queue.queue;
bd->dbgprn_flags = DBGPRN_RD_RQ;