Skip to content

Commit

Permalink
drivers/block/cciss.c: fix check-after-use
Browse files Browse the repository at this point in the history
The Coverity checker spotted that we have already oops'ed if "disk"
was NULL.

Since "disk" being NULL seems impossible at this point this patch
removes the NULL check.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Mike Miller <mike.miller@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Adrian Bunk authored and Linus Torvalds committed Oct 17, 2007
1 parent b012d34 commit 5a9df73
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,38 +1582,36 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
* allows us to delete disk zero but keep the controller registered.
*/
if (h->gendisk[0] != disk) {
if (disk) {
struct request_queue *q = disk->queue;
if (disk->flags & GENHD_FL_UP)
del_gendisk(disk);
if (q) {
blk_cleanup_queue(q);
/* Set drv->queue to NULL so that we do not try
* to call blk_start_queue on this queue in the
* interrupt handler
*/
drv->queue = NULL;
}
/* If clear_all is set then we are deleting the logical
* drive, not just refreshing its info. For drives
* other than disk 0 we will call put_disk. We do not
* do this for disk 0 as we need it to be able to
* configure the controller.
struct request_queue *q = disk->queue;
if (disk->flags & GENHD_FL_UP)
del_gendisk(disk);
if (q) {
blk_cleanup_queue(q);
/* Set drv->queue to NULL so that we do not try
* to call blk_start_queue on this queue in the
* interrupt handler
*/
drv->queue = NULL;
}
/* If clear_all is set then we are deleting the logical
* drive, not just refreshing its info. For drives
* other than disk 0 we will call put_disk. We do not
* do this for disk 0 as we need it to be able to
* configure the controller.
*/
if (clear_all){
/* This isn't pretty, but we need to find the
* disk in our array and NULL our the pointer.
* This is so that we will call alloc_disk if
* this index is used again later.
*/
if (clear_all){
/* This isn't pretty, but we need to find the
* disk in our array and NULL our the pointer.
* This is so that we will call alloc_disk if
* this index is used again later.
*/
for (i=0; i < CISS_MAX_LUN; i++){
if(h->gendisk[i] == disk){
h->gendisk[i] = NULL;
break;
}
for (i=0; i < CISS_MAX_LUN; i++){
if(h->gendisk[i] == disk){
h->gendisk[i] = NULL;
break;
}
put_disk(disk);
}
put_disk(disk);
}
} else {
set_capacity(disk, 0);
Expand Down

0 comments on commit 5a9df73

Please sign in to comment.