Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 251179
b: refs/heads/master
c: abf7966
h: refs/heads/master
i:
  251177: 2c3fb9a
  251175: 8cece50
v: v3
  • Loading branch information
Stephen M. Cameron authored and Jens Axboe committed May 6, 2011
1 parent 0e8a563 commit 7bdcc85
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 54dae3432021f38cf20542ccd152dddb91c7c2d7
refs/heads/master: abf7966e616ef6e04393ef3678227f77d6179a8a
55 changes: 35 additions & 20 deletions trunk/drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -4673,6 +4673,39 @@ static __devinit int cciss_allocate_cmd_pool(ctlr_info_t *h)
return 0;
}

static __devinit int cciss_allocate_scatterlists(ctlr_info_t *h)
{
int i;

/* zero it, so that on free we need not know how many were alloc'ed */
h->scatter_list = kzalloc(h->max_commands *
sizeof(struct scatterlist *), GFP_KERNEL);
if (!h->scatter_list)
return -ENOMEM;

for (i = 0; i < h->nr_cmds; i++) {
h->scatter_list[i] = kmalloc(sizeof(struct scatterlist) *
h->maxsgentries, GFP_KERNEL);
if (h->scatter_list[i] == NULL) {
dev_err(&h->pdev->dev, "could not allocate "
"s/g lists\n");
return -ENOMEM;
}
}
return 0;
}

static void cciss_free_scatterlists(ctlr_info_t *h)
{
int i;

if (h->scatter_list) {
for (i = 0; i < h->nr_cmds; i++)
kfree(h->scatter_list[i]);
kfree(h->scatter_list);
}
}

static void cciss_free_cmd_pool(ctlr_info_t *h)
{
kfree(h->cmd_pool_bits);
Expand All @@ -4696,7 +4729,6 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
{
int i;
int j = 0;
int k = 0;
int rc;
int dac, return_code;
InquiryData_struct *inq_buff;
Expand Down Expand Up @@ -4781,23 +4813,9 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
if (cciss_allocate_cmd_pool(h))
goto clean4;

/* Need space for temp scatter list */
h->scatter_list = kmalloc(h->max_commands *
sizeof(struct scatterlist *),
GFP_KERNEL);
if (!h->scatter_list)
if (cciss_allocate_scatterlists(h))
goto clean4;

for (k = 0; k < h->nr_cmds; k++) {
h->scatter_list[k] = kmalloc(sizeof(struct scatterlist) *
h->maxsgentries,
GFP_KERNEL);
if (h->scatter_list[k] == NULL) {
dev_err(&h->pdev->dev,
"could not allocate s/g lists\n");
goto clean4;
}
}
h->cmd_sg_list = cciss_allocate_sg_chain_blocks(h,
h->chainsize, h->nr_cmds);
if (!h->cmd_sg_list && h->chainsize > 0)
Expand Down Expand Up @@ -4856,10 +4874,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,

clean4:
cciss_free_cmd_pool(h);
/* Free up sg elements */
for (k-- ; k >= 0; k--)
kfree(h->scatter_list[k]);
kfree(h->scatter_list);
cciss_free_scatterlists(h);
cciss_free_sg_chain_blocks(h->cmd_sg_list, h->nr_cmds);
free_irq(h->intr[PERF_MODE_INT], h);
clean2:
Expand Down

0 comments on commit 7bdcc85

Please sign in to comment.