From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Replace general allocations to be zero based. Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/hw/hfi1/chip.c | 6 +++--- drivers/infiniband/hw/hfi1/debugfs.c | 8 ++++---- drivers/infiniband/hw/hfi1/efivar.c | 2 +- drivers/infiniband/hw/hfi1/eprom.c | 6 +++--- drivers/infiniband/hw/hfi1/mmu_rb.c | 2 +- drivers/infiniband/hw/hfi1/pio.c | 3 +-- drivers/infiniband/hw/hfi1/sdma.c | 11 ++++------- drivers/infiniband/hw/hfi1/verbs.c | 2 +- 8 files changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index e6a60fa59f2b..568980ed97ad 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c @@ -12458,7 +12458,7 @@ static int init_cntrs(struct hfi1_devdata *dd) /* allocate space for the counter names */ dd->cntrnameslen = sz; - dd->cntrnames = kmalloc(sz, GFP_KERNEL); + dd->cntrnames = kzalloc(sz, GFP_KERNEL); if (!dd->cntrnames) goto bail; @@ -12560,7 +12560,7 @@ static int init_cntrs(struct hfi1_devdata *dd) /* allocate space for the counter names */ dd->portcntrnameslen = sz; - dd->portcntrnames = kmalloc(sz, GFP_KERNEL); + dd->portcntrnames = kzalloc(sz, GFP_KERNEL); if (!dd->portcntrnames) goto bail; @@ -14256,7 +14256,7 @@ static struct rsm_map_table *alloc_rsm_map_table(struct hfi1_devdata *dd) struct rsm_map_table *rmt; u8 rxcontext = is_ax(dd) ? 0 : 0xff; /* 0 is default if a0 ver. */ - rmt = kmalloc(sizeof(*rmt), GFP_KERNEL); + rmt = kzalloc(sizeof(*rmt), GFP_KERNEL); if (rmt) { memset(rmt->map, rxcontext, sizeof(rmt->map)); rmt->used = 0; diff --git a/drivers/infiniband/hw/hfi1/debugfs.c b/drivers/infiniband/hw/hfi1/debugfs.c index 852173bf05d0..11a5bed42326 100644 --- a/drivers/infiniband/hw/hfi1/debugfs.c +++ b/drivers/infiniband/hw/hfi1/debugfs.c @@ -554,7 +554,7 @@ static ssize_t asic_flags_read(struct file *file, char __user *buf, dd = ppd->dd; size = PAGE_SIZE; used = 0; - tmp = kmalloc(size, GFP_KERNEL); + tmp = kzalloc(size, GFP_KERNEL); if (!tmp) return -ENOMEM; @@ -751,7 +751,7 @@ static ssize_t qsfp_debugfs_dump(struct file *file, char __user *buf, int ret; ppd = private2ppd(file); - tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); + tmp = kzalloc(PAGE_SIZE, GFP_KERNEL); if (!tmp) return -ENOMEM; @@ -837,7 +837,7 @@ static ssize_t __i2c_debugfs_read(struct file *file, char __user *buf, if (i2c_addr == 0) return -EINVAL; - buff = kmalloc(count, GFP_KERNEL); + buff = kzalloc(count, GFP_KERNEL); if (!buff) return -ENOMEM; @@ -939,7 +939,7 @@ static ssize_t __qsfp_debugfs_read(struct file *file, char __user *buf, ppd = private2ppd(file); - buff = kmalloc(count, GFP_KERNEL); + buff = kzalloc(count, GFP_KERNEL); if (!buff) { ret = -ENOMEM; goto _return; diff --git a/drivers/infiniband/hw/hfi1/efivar.c b/drivers/infiniband/hw/hfi1/efivar.c index d106d23016ba..32f70c203682 100644 --- a/drivers/infiniband/hw/hfi1/efivar.c +++ b/drivers/infiniband/hw/hfi1/efivar.c @@ -56,7 +56,7 @@ /* * Read the named EFI variable. Return the size of the actual data in *size - * and a kmalloc'ed buffer in *return_data. The caller must free the + * and a kzalloc'ed buffer in *return_data. The caller must free the * data. It is guaranteed that *return_data will be NULL and *size = 0 * if this routine fails. * diff --git a/drivers/infiniband/hw/hfi1/eprom.c b/drivers/infiniband/hw/hfi1/eprom.c index 1613af1c58d9..19812a3e952d 100644 --- a/drivers/infiniband/hw/hfi1/eprom.c +++ b/drivers/infiniband/hw/hfi1/eprom.c @@ -256,7 +256,7 @@ static int read_partition_platform_config(struct hfi1_devdata *dd, void **data, u32 length; int ret; - buffer = kmalloc(P1_SIZE, GFP_KERNEL); + buffer = kzalloc(P1_SIZE, GFP_KERNEL); if (!buffer) return -ENOMEM; @@ -328,7 +328,7 @@ static int read_segment_platform_config(struct hfi1_devdata *dd, (directory + EP_PAGE_SIZE - directory_size); } else { /* need to allocate and read more */ - table_buffer = kmalloc(directory_size, GFP_KERNEL); + table_buffer = kzalloc(directory_size, GFP_KERNEL); if (!table_buffer) return -ENOMEM; ret = read_length(dd, SEG_SIZE - directory_size, @@ -371,7 +371,7 @@ static int read_segment_platform_config(struct hfi1_devdata *dd, } /* allocate the buffer to return */ - buffer = kmalloc(entry->size, GFP_KERNEL); + buffer = kzalloc(entry->size, GFP_KERNEL); if (!buffer) { ret = -ENOMEM; goto done; diff --git a/drivers/infiniband/hw/hfi1/mmu_rb.c b/drivers/infiniband/hw/hfi1/mmu_rb.c index 70aceefe14d5..bd22ffddb022 100644 --- a/drivers/infiniband/hw/hfi1/mmu_rb.c +++ b/drivers/infiniband/hw/hfi1/mmu_rb.c @@ -102,7 +102,7 @@ int hfi1_mmu_rb_register(void *ops_arg, struct mm_struct *mm, struct mmu_rb_handler *handlr; int ret; - handlr = kmalloc(sizeof(*handlr), GFP_KERNEL); + handlr = kzalloc(sizeof(*handlr), GFP_KERNEL); if (!handlr) return -ENOMEM; diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c index 40dac4d16eb8..f588c4d62db2 100644 --- a/drivers/infiniband/hw/hfi1/pio.c +++ b/drivers/infiniband/hw/hfi1/pio.c @@ -452,8 +452,7 @@ int init_send_contexts(struct hfi1_devdata *dd) if (ret) return ret; - dd->hw_to_sw = kmalloc_array(TXE_NUM_CONTEXTS, sizeof(u8), - GFP_KERNEL); + dd->hw_to_sw = kcalloc(TXE_NUM_CONTEXTS, sizeof(u8), GFP_KERNEL); dd->send_contexts = kcalloc(dd->num_send_contexts, sizeof(struct send_context_info), GFP_KERNEL); diff --git a/drivers/infiniband/hw/hfi1/sdma.c b/drivers/infiniband/hw/hfi1/sdma.c index 1f203309cf24..e5696c70e7a2 100644 --- a/drivers/infiniband/hw/hfi1/sdma.c +++ b/drivers/infiniband/hw/hfi1/sdma.c @@ -1658,7 +1658,7 @@ static inline u8 ahg_mode(struct sdma_txreq *tx) } /** - * __sdma_txclean() - clean tx of mappings, descp *kmalloc's + * __sdma_txclean() - clean tx of mappings, descp *kzalloc's * @dd: hfi1_devdata for unmapping * @tx: tx request to clean * @@ -1688,7 +1688,7 @@ void __sdma_txclean( } kfree(tx->coalesce_buf); tx->coalesce_buf = NULL; - /* kmalloc'ed descp */ + /* kzalloc'ed descp */ if (unlikely(tx->desc_limit > ARRAY_SIZE(tx->descs))) { tx->desc_limit = ARRAY_SIZE(tx->descs); kfree(tx->descp); @@ -3067,7 +3067,7 @@ static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx) tx->desc_limit = MAX_DESC; } else if (!tx->coalesce_buf) { /* allocate coalesce buffer with space for padding */ - tx->coalesce_buf = kmalloc(tx->tlen + sizeof(u32), + tx->coalesce_buf = kzalloc(tx->tlen + sizeof(u32), GFP_ATOMIC); if (!tx->coalesce_buf) goto enomem; @@ -3079,10 +3079,7 @@ static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx) if (unlikely(tx->num_desc == MAX_DESC)) goto enomem; - tx->descp = kmalloc_array( - MAX_DESC, - sizeof(struct sdma_desc), - GFP_ATOMIC); + tx->descp = kcalloc(MAX_DESC, sizeof(struct sdma_desc), GFP_ATOMIC); if (!tx->descp) goto enomem; diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c index c8cf4d4984d3..0f0bc0888983 100644 --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c @@ -1718,7 +1718,7 @@ static int init_cntr_names(const char *names_in, if (names_in[i] == '\n') n++; - names_out = kmalloc((n + num_extra_names) * sizeof(char *) + names_len, + names_out = kzalloc((n + num_extra_names) * sizeof(char *) + names_len, GFP_KERNEL); if (!names_out) { *num_cntrs = 0; -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html