Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d61c4269 authored by Stephen M. Cameron's avatar Stephen M. Cameron Committed by Jens Axboe
Browse files

cciss: fix scatter gather cleanup problems



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: default avatarDon Brace <brace@beardog.cce.hp.com>
Signed-off-by: default avatarStephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 87038c2d
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -4326,11 +4326,16 @@ 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);
	/* 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])
			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,
				    hba[i]->nr_cmds * sizeof(CommandList_struct),
@@ -4448,10 +4453,16 @@ 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);
	/* 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
	 * Smart Array controllers that pci_enable_device does not undo