Skip to content

Commit

Permalink
cciss: fix scatter gather cleanup problems
Browse files Browse the repository at this point in the history
On driver unload, only free up the extra scatter gather data if they were
allocated in the first place (the controller supports it) and don't forget
to free up the sg_cmd_list array of pointers.

Signed-off-by: Don Brace <brace@beardog.cce.hp.com>
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 Nov 23, 2009
1 parent 87038c2 commit d61c426
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -4326,10 +4326,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
for (k = 0; k < hba[i]->nr_cmds; k++)
kfree(hba[i]->scatter_list[k]);
kfree(hba[i]->scatter_list);
for (j = 0; j < hba[i]->nr_cmds; j++) {
if (hba[i]->cmd_sg_list[j])
kfree(hba[i]->cmd_sg_list[j]->sgchain);
kfree(hba[i]->cmd_sg_list[j]);
/* Only free up extra s/g lists if controller supports them */
if (hba[i]->chainsize > 0) {
for (j = 0; j < hba[i]->nr_cmds; j++) {
if (hba[i]->cmd_sg_list[j]) {
kfree(hba[i]->cmd_sg_list[j]->sgchain);
kfree(hba[i]->cmd_sg_list[j]);
}
}
kfree(hba[i]->cmd_sg_list);
}
if (hba[i]->cmd_pool)
pci_free_consistent(hba[i]->pdev,
Expand Down Expand Up @@ -4448,9 +4453,15 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
for (j = 0; j < hba[i]->nr_cmds; j++)
kfree(hba[i]->scatter_list[j]);
kfree(hba[i]->scatter_list);
for (j = 0; j < hba[i]->nr_cmds; j++) {
kfree(hba[i]->cmd_sg_list[j]->sgchain);
kfree(hba[i]->cmd_sg_list[j]);
/* Only free up extra s/g lists if controller supports them */
if (hba[i]->chainsize > 0) {
for (j = 0; j < hba[i]->nr_cmds; j++) {
if (hba[i]->cmd_sg_list[j]) {
kfree(hba[i]->cmd_sg_list[j]->sgchain);
kfree(hba[i]->cmd_sg_list[j]);
}
}
kfree(hba[i]->cmd_sg_list);
}
/*
* Deliberately omit pci_disable_device(): it does something nasty to
Expand Down

0 comments on commit d61c426

Please sign in to comment.