diff options
Diffstat (limited to 'drivers/scsi/hpsa.c')
| -rw-r--r-- | drivers/scsi/hpsa.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 3a9eca163db8..af0e628ff396 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
| @@ -1923,8 +1923,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, | |||
| 1923 | } | 1923 | } |
| 1924 | spin_unlock_irqrestore(&h->reset_lock, flags); | 1924 | spin_unlock_irqrestore(&h->reset_lock, flags); |
| 1925 | 1925 | ||
| 1926 | added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); | 1926 | added = kcalloc(HPSA_MAX_DEVICES, sizeof(*added), GFP_KERNEL); |
| 1927 | removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); | 1927 | removed = kcalloc(HPSA_MAX_DEVICES, sizeof(*removed), GFP_KERNEL); |
| 1928 | 1928 | ||
| 1929 | if (!added || !removed) { | 1929 | if (!added || !removed) { |
| 1930 | dev_warn(&h->pdev->dev, "out of memory in " | 1930 | dev_warn(&h->pdev->dev, "out of memory in " |
| @@ -2171,14 +2171,15 @@ static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) | |||
| 2171 | return 0; | 2171 | return 0; |
| 2172 | 2172 | ||
| 2173 | h->ioaccel2_cmd_sg_list = | 2173 | h->ioaccel2_cmd_sg_list = |
| 2174 | kzalloc(sizeof(*h->ioaccel2_cmd_sg_list) * h->nr_cmds, | 2174 | kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), |
| 2175 | GFP_KERNEL); | 2175 | GFP_KERNEL); |
| 2176 | if (!h->ioaccel2_cmd_sg_list) | 2176 | if (!h->ioaccel2_cmd_sg_list) |
| 2177 | return -ENOMEM; | 2177 | return -ENOMEM; |
| 2178 | for (i = 0; i < h->nr_cmds; i++) { | 2178 | for (i = 0; i < h->nr_cmds; i++) { |
| 2179 | h->ioaccel2_cmd_sg_list[i] = | 2179 | h->ioaccel2_cmd_sg_list[i] = |
| 2180 | kmalloc(sizeof(*h->ioaccel2_cmd_sg_list[i]) * | 2180 | kmalloc_array(h->maxsgentries, |
| 2181 | h->maxsgentries, GFP_KERNEL); | 2181 | sizeof(*h->ioaccel2_cmd_sg_list[i]), |
| 2182 | GFP_KERNEL); | ||
| 2182 | if (!h->ioaccel2_cmd_sg_list[i]) | 2183 | if (!h->ioaccel2_cmd_sg_list[i]) |
| 2183 | goto clean; | 2184 | goto clean; |
| 2184 | } | 2185 | } |
| @@ -2210,14 +2211,15 @@ static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) | |||
| 2210 | if (h->chainsize <= 0) | 2211 | if (h->chainsize <= 0) |
| 2211 | return 0; | 2212 | return 0; |
| 2212 | 2213 | ||
| 2213 | h->cmd_sg_list = kzalloc(sizeof(*h->cmd_sg_list) * h->nr_cmds, | 2214 | h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), |
| 2214 | GFP_KERNEL); | 2215 | GFP_KERNEL); |
| 2215 | if (!h->cmd_sg_list) | 2216 | if (!h->cmd_sg_list) |
| 2216 | return -ENOMEM; | 2217 | return -ENOMEM; |
| 2217 | 2218 | ||
| 2218 | for (i = 0; i < h->nr_cmds; i++) { | 2219 | for (i = 0; i < h->nr_cmds; i++) { |
| 2219 | h->cmd_sg_list[i] = kmalloc(sizeof(*h->cmd_sg_list[i]) * | 2220 | h->cmd_sg_list[i] = kmalloc_array(h->chainsize, |
| 2220 | h->chainsize, GFP_KERNEL); | 2221 | sizeof(*h->cmd_sg_list[i]), |
| 2222 | GFP_KERNEL); | ||
| 2221 | if (!h->cmd_sg_list[i]) | 2223 | if (!h->cmd_sg_list[i]) |
| 2222 | goto clean; | 2224 | goto clean; |
| 2223 | 2225 | ||
| @@ -4319,7 +4321,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) | |||
| 4319 | bool physical_device; | 4321 | bool physical_device; |
| 4320 | DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); | 4322 | DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); |
| 4321 | 4323 | ||
| 4322 | currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL); | 4324 | currentsd = kcalloc(HPSA_MAX_DEVICES, sizeof(*currentsd), GFP_KERNEL); |
| 4323 | physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL); | 4325 | physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL); |
| 4324 | logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL); | 4326 | logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL); |
| 4325 | tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL); | 4327 | tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL); |
| @@ -6402,12 +6404,12 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) | |||
| 6402 | status = -EINVAL; | 6404 | status = -EINVAL; |
| 6403 | goto cleanup1; | 6405 | goto cleanup1; |
| 6404 | } | 6406 | } |
| 6405 | buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL); | 6407 | buff = kcalloc(SG_ENTRIES_IN_CMD, sizeof(char *), GFP_KERNEL); |
| 6406 | if (!buff) { | 6408 | if (!buff) { |
| 6407 | status = -ENOMEM; | 6409 | status = -ENOMEM; |
| 6408 | goto cleanup1; | 6410 | goto cleanup1; |
| 6409 | } | 6411 | } |
| 6410 | buff_size = kmalloc(SG_ENTRIES_IN_CMD * sizeof(int), GFP_KERNEL); | 6412 | buff_size = kmalloc_array(SG_ENTRIES_IN_CMD, sizeof(int), GFP_KERNEL); |
| 6411 | if (!buff_size) { | 6413 | if (!buff_size) { |
| 6412 | status = -ENOMEM; | 6414 | status = -ENOMEM; |
| 6413 | goto cleanup1; | 6415 | goto cleanup1; |
| @@ -7151,7 +7153,7 @@ static int controller_reset_failed(struct CfgTable __iomem *cfgtable) | |||
| 7151 | char *driver_ver, *old_driver_ver; | 7153 | char *driver_ver, *old_driver_ver; |
| 7152 | int rc, size = sizeof(cfgtable->driver_version); | 7154 | int rc, size = sizeof(cfgtable->driver_version); |
| 7153 | 7155 | ||
| 7154 | old_driver_ver = kmalloc(2 * size, GFP_KERNEL); | 7156 | old_driver_ver = kmalloc_array(2, size, GFP_KERNEL); |
| 7155 | if (!old_driver_ver) | 7157 | if (!old_driver_ver) |
| 7156 | return -ENOMEM; | 7158 | return -ENOMEM; |
| 7157 | driver_ver = old_driver_ver + size; | 7159 | driver_ver = old_driver_ver + size; |
| @@ -7931,9 +7933,9 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h) | |||
| 7931 | 7933 | ||
| 7932 | static int hpsa_alloc_cmd_pool(struct ctlr_info *h) | 7934 | static int hpsa_alloc_cmd_pool(struct ctlr_info *h) |
| 7933 | { | 7935 | { |
| 7934 | h->cmd_pool_bits = kzalloc( | 7936 | h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG), |
| 7935 | DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) * | 7937 | sizeof(unsigned long), |
| 7936 | sizeof(unsigned long), GFP_KERNEL); | 7938 | GFP_KERNEL); |
| 7937 | h->cmd_pool = pci_alloc_consistent(h->pdev, | 7939 | h->cmd_pool = pci_alloc_consistent(h->pdev, |
| 7938 | h->nr_cmds * sizeof(*h->cmd_pool), | 7940 | h->nr_cmds * sizeof(*h->cmd_pool), |
| 7939 | &(h->cmd_pool_dhandle)); | 7941 | &(h->cmd_pool_dhandle)); |
| @@ -8507,7 +8509,7 @@ static struct ctlr_info *hpda_alloc_ctlr_info(void) | |||
| 8507 | if (!h) | 8509 | if (!h) |
| 8508 | return NULL; | 8510 | return NULL; |
| 8509 | 8511 | ||
| 8510 | h->reply_map = kzalloc(sizeof(*h->reply_map) * nr_cpu_ids, GFP_KERNEL); | 8512 | h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); |
| 8511 | if (!h->reply_map) { | 8513 | if (!h->reply_map) { |
| 8512 | kfree(h); | 8514 | kfree(h); |
| 8513 | return NULL; | 8515 | return NULL; |
