From: Leon Romanovsky <leonro@xxxxxxxxxxxx> Replace general allocations to be zero based. Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- drivers/infiniband/hw/qib/qib_diag.c | 8 ++++---- drivers/infiniband/hw/qib/qib_file_ops.c | 4 ++-- drivers/infiniband/hw/qib/qib_fs.c | 6 +++--- drivers/infiniband/hw/qib/qib_iba6120.c | 4 ++-- drivers/infiniband/hw/qib/qib_iba7220.c | 4 ++-- drivers/infiniband/hw/qib/qib_iba7322.c | 12 ++++++------ drivers/infiniband/hw/qib/qib_init.c | 8 ++++---- drivers/infiniband/hw/qib/qib_user_sdma.c | 20 ++++++++++---------- drivers/infiniband/hw/qib/qib_verbs.c | 2 +- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/infiniband/hw/qib/qib_diag.c b/drivers/infiniband/hw/qib/qib_diag.c index a9377eee8734..d8ff8d0580d2 100644 --- a/drivers/infiniband/hw/qib/qib_diag.c +++ b/drivers/infiniband/hw/qib/qib_diag.c @@ -72,7 +72,7 @@ static struct qib_diag_client { } *client_pool; /* - * Get a client struct. Recycled if possible, else kmalloc. + * Get a client struct. Recycled if possible, else kzalloc. * Must be called with qib_mutex held */ static struct qib_diag_client *get_client(struct qib_devdata *dd) @@ -85,7 +85,7 @@ static struct qib_diag_client *get_client(struct qib_devdata *dd) client_pool = dc->next; else /* None in pool, alloc and init */ - dc = kmalloc(sizeof(*dc), GFP_KERNEL); + dc = kzalloc(sizeof(*dc), GFP_KERNEL); if (dc) { dc->next = NULL; @@ -607,7 +607,7 @@ static ssize_t qib_diagpkt_write(struct file *fp, plen = sizeof(u32) + dp.len; - tmpbuf = vmalloc(plen); + tmpbuf = vzalloc(plen); if (!tmpbuf) { ret = -ENOMEM; goto bail; @@ -699,7 +699,7 @@ int qib_register_observer(struct qib_devdata *dd, if (!dd || !op) return -EINVAL; - olp = vmalloc(sizeof(*olp)); + olp = vzalloc(sizeof(*olp)); if (!olp) return -ENOMEM; diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c index 52c29db3a2f4..e9bc6c036cf0 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c @@ -1300,7 +1300,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, * reduce cost of expected send setup per message segment */ if (rcd) - ptmp = kmalloc(dd->rcvtidcnt * sizeof(u16) + + ptmp = kzalloc(dd->rcvtidcnt * sizeof(u16) + dd->rcvtidcnt * sizeof(struct page **), GFP_KERNEL); @@ -2245,7 +2245,7 @@ static ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from) if (!iter_is_iovec(from) || !from->nr_segs || !pq) return -EINVAL; - + return qib_user_sdma_writev(rcd, pq, from->iov, from->nr_segs); } diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index 1d940a2885c9..43fd1bc95d6e 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -227,7 +227,7 @@ static ssize_t qsfp_1_read(struct file *file, char __user *buf, char *tmp; int ret; - tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); + tmp = kzalloc(PAGE_SIZE, GFP_KERNEL); if (!tmp) return -ENOMEM; @@ -251,7 +251,7 @@ static ssize_t qsfp_2_read(struct file *file, char __user *buf, if (dd->num_pports < 2) return -ENODEV; - tmp = kmalloc(PAGE_SIZE, GFP_KERNEL); + tmp = kzalloc(PAGE_SIZE, GFP_KERNEL); if (!tmp) return -ENOMEM; @@ -290,7 +290,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, if (count > sizeof(struct qib_flash) - pos) count = sizeof(struct qib_flash) - pos; - tmp = kmalloc(count, GFP_KERNEL); + tmp = kzalloc(count, GFP_KERNEL); if (!tmp) { ret = -ENOMEM; goto bail; diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c index 8a15e5c7dd91..4330a2a749c0 100644 --- a/drivers/infiniband/hw/qib/qib_iba6120.c +++ b/drivers/infiniband/hw/qib/qib_iba6120.c @@ -2496,14 +2496,14 @@ static void init_6120_cntrnames(struct qib_devdata *dd) dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1; else dd->cspec->cntrnamelen = 1 + s - cntr6120names; - dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs + dd->cspec->cntrs = kzalloc(dd->cspec->ncntrs * sizeof(u64), GFP_KERNEL); for (i = 0, s = (char *)portcntr6120names; s; i++) s = strchr(s + 1, '\n'); dd->cspec->nportcntrs = i - 1; dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1; - dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs + dd->cspec->portcntrs = kzalloc(dd->cspec->nportcntrs * sizeof(u64), GFP_KERNEL); } diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c index bdff2326731e..cfaa856988b6 100644 --- a/drivers/infiniband/hw/qib/qib_iba7220.c +++ b/drivers/infiniband/hw/qib/qib_iba7220.c @@ -3147,14 +3147,14 @@ static void init_7220_cntrnames(struct qib_devdata *dd) dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1; else dd->cspec->cntrnamelen = 1 + s - cntr7220names; - dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs + dd->cspec->cntrs = kzalloc(dd->cspec->ncntrs * sizeof(u64), GFP_KERNEL); for (i = 0, s = (char *)portcntr7220names; s; i++) s = strchr(s + 1, '\n'); dd->cspec->nportcntrs = i - 1; dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1; - dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs + dd->cspec->portcntrs = kzalloc(dd->cspec->nportcntrs * sizeof(u64), GFP_KERNEL); } diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 8414ae44a518..6e0483adcaa2 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c @@ -3648,7 +3648,7 @@ static int qib_do_7322_reset(struct qib_devdata *dd) if (msix_entries) { /* can be up to 512 bytes, too big for stack */ - msix_vecsave = kmalloc(2 * dd->cspec->num_msix_entries * + msix_vecsave = kzalloc(2 * dd->cspec->num_msix_entries * sizeof(u64), GFP_KERNEL); } @@ -5009,7 +5009,7 @@ static void init_7322_cntrnames(struct qib_devdata *dd) dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1; else dd->cspec->cntrnamelen = 1 + s - cntr7322names; - dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs + dd->cspec->cntrs = kzalloc(dd->cspec->ncntrs * sizeof(u64), GFP_KERNEL); for (i = 0, s = (char *)portcntr7322names; s; i++) @@ -5017,7 +5017,7 @@ static void init_7322_cntrnames(struct qib_devdata *dd) dd->cspec->nportcntrs = i - 1; dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1; for (i = 0; i < dd->num_pports; ++i) { - dd->pport[i].cpspec->portcntrs = kmalloc(dd->cspec->nportcntrs + dd->pport[i].cpspec->portcntrs = kzalloc(dd->cspec->nportcntrs * sizeof(u64), GFP_KERNEL); } } @@ -6412,11 +6412,11 @@ static int qib_init_7322_variables(struct qib_devdata *dd) sbufcnt = dd->piobcnt2k + dd->piobcnt4k + NUM_VL15_BUFS + BITS_PER_LONG - 1; sbufcnt /= BITS_PER_LONG; - dd->cspec->sendchkenable = kmalloc(sbufcnt * + dd->cspec->sendchkenable = kzalloc(sbufcnt * sizeof(*dd->cspec->sendchkenable), GFP_KERNEL); - dd->cspec->sendgrhchk = kmalloc(sbufcnt * + dd->cspec->sendgrhchk = kzalloc(sbufcnt * sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL); - dd->cspec->sendibchk = kmalloc(sbufcnt * + dd->cspec->sendibchk = kzalloc(sbufcnt * sizeof(*dd->cspec->sendibchk), GFP_KERNEL); if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk || !dd->cspec->sendibchk) { diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 6c68f8a97018..0a29d281d7ef 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c @@ -988,7 +988,7 @@ static void qib_verify_pioperf(struct qib_devdata *dd) */ cnt = 1024; - addr = vmalloc(cnt); + addr = vzalloc(cnt); if (!addr) goto done; @@ -1667,9 +1667,9 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd) } if (!rcd->rcvegrbuf_phys) { rcd->rcvegrbuf_phys = - kmalloc_array_node(chunk, - sizeof(rcd->rcvegrbuf_phys[0]), - GFP_KERNEL, rcd->node_id); + kcalloc_node(chunk, + sizeof(rcd->rcvegrbuf_phys[0]), + GFP_KERNEL, rcd->node_id); if (!rcd->rcvegrbuf_phys) goto bail_rcvegrbuf; } diff --git a/drivers/infiniband/hw/qib/qib_user_sdma.c b/drivers/infiniband/hw/qib/qib_user_sdma.c index 926f3c8eba69..7c04efa3b1e0 100644 --- a/drivers/infiniband/hw/qib/qib_user_sdma.c +++ b/drivers/infiniband/hw/qib/qib_user_sdma.c @@ -67,7 +67,7 @@ struct qib_user_sdma_pkt { struct list_head list; /* list element */ u8 tiddma; /* if this is NEW tid-sdma */ - u8 largepkt; /* this is large pkt from kmalloc */ + u8 largepkt; /* this is large pkt from kzalloc */ u16 frag_size; /* frag size used by PSM */ u16 index; /* last header index or push index */ u16 naddr; /* dimension of addr (1..3) ... */ @@ -183,7 +183,7 @@ struct qib_user_sdma_queue * qib_user_sdma_queue_create(struct device *dev, int unit, int ctxt, int sctxt) { struct qib_user_sdma_queue *pq = - kmalloc(sizeof(struct qib_user_sdma_queue), GFP_KERNEL); + kzalloc(sizeof(struct qib_user_sdma_queue), GFP_KERNEL); struct qib_user_sdma_rb_node *sdma_rb_node; if (!pq) @@ -227,7 +227,7 @@ qib_user_sdma_queue_create(struct device *dev, int unit, int ctxt, int sctxt) } else { int ret; - sdma_rb_node = kmalloc(sizeof( + sdma_rb_node = kzalloc(sizeof( struct qib_user_sdma_rb_node), GFP_KERNEL); if (!sdma_rb_node) goto err_rb; @@ -286,7 +286,7 @@ static void *qib_user_sdma_alloc_header(struct qib_user_sdma_queue *pq, hdr = NULL; if (!hdr) { - hdr = kmalloc(len, GFP_KERNEL); + hdr = kzalloc(len, GFP_KERNEL); if (!hdr) return NULL; @@ -382,7 +382,7 @@ static int qib_user_sdma_page_to_frags(const struct qib_devdata *dd, /* If there is no more byte togo. (lastdesc==1) */ if (pkt->bytes_togo == 0) { /* The packet is done, header is not dma mapped yet. - * it should be from kmalloc */ + * it should be from kzalloc */ if (!pkt->addr[pkt->index].addr) { pkt->addr[pkt->index].addr = dma_map_single(&dd->pcidev->dev, @@ -473,7 +473,7 @@ static int qib_user_sdma_page_to_frags(const struct qib_devdata *dd, le16_to_cpu(hdr->iph.pkt_flags)); /* The packet is done, header is not dma mapped yet. - * it should be from kmalloc */ + * it should be from kzalloc */ if (!pkt->addr[pkt->index].addr) { pkt->addr[pkt->index].addr = dma_map_single(&dd->pcidev->dev, @@ -641,7 +641,7 @@ static void qib_user_sdma_free_pkt_frag(struct device *dev, } else if (pkt->addr[i].kvaddr) { /* for headers */ if (pkt->addr[i].dma_mapped) { - /* from kmalloc & dma mapped */ + /* from kzalloc & dma mapped */ dma_unmap_single(dev, pkt->addr[i].addr, pkt->addr[i].dma_length, @@ -652,7 +652,7 @@ static void qib_user_sdma_free_pkt_frag(struct device *dev, dma_pool_free(pq->header_cache, pkt->addr[i].kvaddr, pkt->addr[i].addr); } else { - /* from kmalloc but not dma mapped */ + /* from kzalloc but not dma mapped */ kfree(pkt->addr[i].kvaddr); } } @@ -926,7 +926,7 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd, else tidsmsize = 0; - pkt = kmalloc(pktsize+tidsmsize, GFP_KERNEL); + pkt = kzalloc(pktsize+tidsmsize, GFP_KERNEL); if (!pkt) { ret = -ENOMEM; goto free_pbc; @@ -997,7 +997,7 @@ static int qib_user_sdma_queue_pkts(const struct qib_devdata *dd, if (dma_addr == 0) { /* * the header is not dma mapped yet. - * it should be from kmalloc. + * it should be from kzalloc. */ dma_addr = dma_map_single(&dd->pcidev->dev, pbc, len, DMA_TO_DEVICE); diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c index 3977abbc83ad..cdff461d4053 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.c +++ b/drivers/infiniband/hw/qib/qib_verbs.c @@ -870,7 +870,7 @@ static int qib_verbs_send_dma(struct rvt_qp *qp, struct ib_header *hdr, /* Allocate a buffer and copy the header and payload to it. */ tx->hdr_dwords = plen + 1; - phdr = kmalloc(tx->hdr_dwords << 2, GFP_ATOMIC); + phdr = kzalloc(tx->hdr_dwords << 2, GFP_ATOMIC); if (!phdr) goto err_tx; phdr->pbc[0] = cpu_to_le32(plen); -- 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