diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-10-23 04:36:08 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-12-29 12:24:11 -0500 |
commit | e98991130df36bc429f341a2f21519c39c52afe3 (patch) | |
tree | 3181784b0c06de8106c93e4df3cce26cc80b5488 /drivers/scsi/aacraid | |
parent | 25729a7fb88ef2912fcb869abe3a76b3be07fc06 (diff) |
[SCSI] aacraid: check pci_alloc_consistent errors
We need to check the address that pci_alloc_consistent() returns since
it might fail.
When pci_alloc_consistent() fails, some IOMMUs set the dma_handle
argument to zero. So we can't use fibptr->hw_fib_pa directly here.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Aacraid List <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/aacraid')
-rw-r--r-- | drivers/scsi/aacraid/commctrl.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index a7355260cfcf..a5ebf8f49fa8 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c | |||
@@ -90,14 +90,24 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) | |||
90 | if (size < le16_to_cpu(kfib->header.SenderSize)) | 90 | if (size < le16_to_cpu(kfib->header.SenderSize)) |
91 | size = le16_to_cpu(kfib->header.SenderSize); | 91 | size = le16_to_cpu(kfib->header.SenderSize); |
92 | if (size > dev->max_fib_size) { | 92 | if (size > dev->max_fib_size) { |
93 | dma_addr_t daddr; | ||
94 | |||
93 | if (size > 2048) { | 95 | if (size > 2048) { |
94 | retval = -EINVAL; | 96 | retval = -EINVAL; |
95 | goto cleanup; | 97 | goto cleanup; |
96 | } | 98 | } |
99 | |||
100 | kfib = pci_alloc_consistent(dev->pdev, size, &daddr); | ||
101 | if (!kfib) { | ||
102 | retval = -ENOMEM; | ||
103 | goto cleanup; | ||
104 | } | ||
105 | |||
97 | /* Highjack the hw_fib */ | 106 | /* Highjack the hw_fib */ |
98 | hw_fib = fibptr->hw_fib_va; | 107 | hw_fib = fibptr->hw_fib_va; |
99 | hw_fib_pa = fibptr->hw_fib_pa; | 108 | hw_fib_pa = fibptr->hw_fib_pa; |
100 | fibptr->hw_fib_va = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa); | 109 | fibptr->hw_fib_va = kfib; |
110 | fibptr->hw_fib_pa = daddr; | ||
101 | memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size); | 111 | memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size); |
102 | memcpy(kfib, hw_fib, dev->max_fib_size); | 112 | memcpy(kfib, hw_fib, dev->max_fib_size); |
103 | } | 113 | } |