Skip to content

Commit

Permalink
cciss: Fix excessive gendisk freeing bug on driver unload.
Browse files Browse the repository at this point in the history
Fix bug that free_hba was calling put_disk for all gendisk[]
pointers -- all 1024 of them -- regardless of whether the were
used or not (NULL).  This bug could cause rmmod to oops if logical
drives had been deleted during the driver's lifetime.

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Stephen M. Cameron authored and Jens Axboe committed Oct 1, 2009
1 parent 2d11d99 commit 2c93559
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -3893,15 +3893,16 @@ static int alloc_cciss_hba(void)
return -1;
}

static void free_hba(int i)
static void free_hba(int n)
{
ctlr_info_t *p = hba[i];
int n;
ctlr_info_t *h = hba[n];
int i;

hba[i] = NULL;
for (n = 0; n < CISS_MAX_LUN; n++)
put_disk(p->gendisk[n]);
kfree(p);
hba[n] = NULL;
for (i = 0; i < h->highest_lun + 1; i++)
if (h->gendisk[i] != NULL)
put_disk(h->gendisk[i]);
kfree(h);
}

/* Send a message CDB to the firmware. */
Expand Down

0 comments on commit 2c93559

Please sign in to comment.