RE: [PATCH rdma-next 08/15] RDMA/cxgb4: Zero all allocated memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Replace general allocations to be zero based.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>

Looks good.

Reviewed-by: Steve Wise <swise@xxxxxxxxxxxxxxxxxxxxx>

> ---
>  drivers/infiniband/hw/cxgb4/cq.c       |  4 ++--
>  drivers/infiniband/hw/cxgb4/device.c   | 12 ++++++------
>  drivers/infiniband/hw/cxgb4/id_table.c |  2 +-
>  drivers/infiniband/hw/cxgb4/provider.c |  4 ++--
>  drivers/infiniband/hw/cxgb4/qp.c       | 10 +++++-----
>  drivers/infiniband/hw/cxgb4/resource.c | 16 ++++++++--------
>  6 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/cxgb4/cq.c
b/drivers/infiniband/hw/cxgb4/cq.c
> index 6f2b26126c64..77810c6ae055 100644
> --- a/drivers/infiniband/hw/cxgb4/cq.c
> +++ b/drivers/infiniband/hw/cxgb4/cq.c
> @@ -955,10 +955,10 @@ struct ib_cq *c4iw_create_cq(struct ib_device
*ibdev,
> 
>  	if (ucontext) {
>  		ret = -ENOMEM;
> -		mm = kmalloc(sizeof *mm, GFP_KERNEL);
> +		mm = kzalloc(sizeof *mm, GFP_KERNEL);
>  		if (!mm)
>  			goto err_remove_handle;
> -		mm2 = kmalloc(sizeof *mm2, GFP_KERNEL);
> +		mm2 = kzalloc(sizeof *mm2, GFP_KERNEL);
>  		if (!mm2)
>  			goto err_free_mm;
> 
> diff --git a/drivers/infiniband/hw/cxgb4/device.c
> b/drivers/infiniband/hw/cxgb4/device.c
> index 7a9d0de89d6a..179aa04f303b 100644
> --- a/drivers/infiniband/hw/cxgb4/device.c
> +++ b/drivers/infiniband/hw/cxgb4/device.c
> @@ -337,7 +337,7 @@ static int qp_open(struct inode *inode, struct file
*file)
>  	struct c4iw_debugfs_data *qpd;
>  	int count = 1;
> 
> -	qpd = kmalloc(sizeof *qpd, GFP_KERNEL);
> +	qpd = kzalloc(sizeof *qpd, GFP_KERNEL);
>  	if (!qpd)
>  		return -ENOMEM;
> 
> @@ -349,7 +349,7 @@ static int qp_open(struct inode *inode, struct file
*file)
>  	spin_unlock_irq(&qpd->devp->lock);
> 
>  	qpd->bufsize = count * 180;
> -	qpd->buf = vmalloc(qpd->bufsize);
> +	qpd->buf = vzalloc(qpd->bufsize);
>  	if (!qpd->buf) {
>  		kfree(qpd);
>  		return -ENOMEM;
> @@ -426,7 +426,7 @@ static int stag_open(struct inode *inode, struct file
*file)
>  	int ret = 0;
>  	int count = 1;
> 
> -	stagd = kmalloc(sizeof *stagd, GFP_KERNEL);
> +	stagd = kzalloc(sizeof *stagd, GFP_KERNEL);
>  	if (!stagd) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -439,7 +439,7 @@ static int stag_open(struct inode *inode, struct file
*file)
>  	spin_unlock_irq(&stagd->devp->lock);
> 
>  	stagd->bufsize = count * 256;
> -	stagd->buf = vmalloc(stagd->bufsize);
> +	stagd->buf = vzalloc(stagd->bufsize);
>  	if (!stagd->buf) {
>  		ret = -ENOMEM;
>  		goto err1;
> @@ -672,7 +672,7 @@ static int ep_open(struct inode *inode, struct file
*file)
>  	int ret = 0;
>  	int count = 1;
> 
> -	epd = kmalloc(sizeof(*epd), GFP_KERNEL);
> +	epd = kzalloc(sizeof(*epd), GFP_KERNEL);
>  	if (!epd) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -687,7 +687,7 @@ static int ep_open(struct inode *inode, struct file
*file)
>  	spin_unlock_irq(&epd->devp->lock);
> 
>  	epd->bufsize = count * 240;
> -	epd->buf = vmalloc(epd->bufsize);
> +	epd->buf = vzalloc(epd->bufsize);
>  	if (!epd->buf) {
>  		ret = -ENOMEM;
>  		goto err1;
> diff --git a/drivers/infiniband/hw/cxgb4/id_table.c
> b/drivers/infiniband/hw/cxgb4/id_table.c
> index 5c2cfdea06ad..b2d2fe53be82 100644
> --- a/drivers/infiniband/hw/cxgb4/id_table.c
> +++ b/drivers/infiniband/hw/cxgb4/id_table.c
> @@ -92,7 +92,7 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32
> start, u32 num,
>  		alloc->last = 0;
>  	alloc->max  = num;
>  	spin_lock_init(&alloc->lock);
> -	alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long),
> +	alloc->table = kzalloc(BITS_TO_LONGS(num) * sizeof(long),
>  				GFP_KERNEL);
>  	if (!alloc->table)
>  		return -ENOMEM;
> diff --git a/drivers/infiniband/hw/cxgb4/provider.c
> b/drivers/infiniband/hw/cxgb4/provider.c
> index db02c39d4a12..4daba0461029 100644
> --- a/drivers/infiniband/hw/cxgb4/provider.c
> +++ b/drivers/infiniband/hw/cxgb4/provider.c
> @@ -143,7 +143,7 @@ static struct ib_ucontext *c4iw_alloc_ucontext(struct
> ib_device *ibdev,
>  		pr_err_once("Warning - downlevel libcxgb4 (non-fatal),
device
> status page disabled\n");
>  		rhp->rdev.flags |= T4_STATUS_PAGE_DISABLED;
>  	} else {
> -		mm = kmalloc(sizeof(*mm), GFP_KERNEL);
> +		mm = kzalloc(sizeof(*mm), GFP_KERNEL);
>  		if (!mm) {
>  			ret = -ENOMEM;
>  			goto err_free;
> @@ -610,7 +610,7 @@ void c4iw_register_device(struct work_struct *work)
>  	dev->ibdev.get_port_immutable = c4iw_port_immutable;
>  	dev->ibdev.get_dev_fw_str = get_dev_fw_str;
> 
> -	dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
> +	dev->ibdev.iwcm = kzalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
>  	if (!dev->ibdev.iwcm) {
>  		ret = -ENOMEM;
>  		goto err_dealloc_ctx;
> diff --git a/drivers/infiniband/hw/cxgb4/qp.c
> b/drivers/infiniband/hw/cxgb4/qp.c
> index de77b6027d69..7d444a1473b3 100644
> --- a/drivers/infiniband/hw/cxgb4/qp.c
> +++ b/drivers/infiniband/hw/cxgb4/qp.c
> @@ -1920,28 +1920,28 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd,
> struct ib_qp_init_attr *attrs,
>  		goto err_destroy_qp;
> 
>  	if (udata && ucontext) {
> -		sq_key_mm = kmalloc(sizeof(*sq_key_mm), GFP_KERNEL);
> +		sq_key_mm = kzalloc(sizeof(*sq_key_mm), GFP_KERNEL);
>  		if (!sq_key_mm) {
>  			ret = -ENOMEM;
>  			goto err_remove_handle;
>  		}
> -		rq_key_mm = kmalloc(sizeof(*rq_key_mm), GFP_KERNEL);
> +		rq_key_mm = kzalloc(sizeof(*rq_key_mm), GFP_KERNEL);
>  		if (!rq_key_mm) {
>  			ret = -ENOMEM;
>  			goto err_free_sq_key;
>  		}
> -		sq_db_key_mm = kmalloc(sizeof(*sq_db_key_mm),
> GFP_KERNEL);
> +		sq_db_key_mm = kzalloc(sizeof(*sq_db_key_mm),
> GFP_KERNEL);
>  		if (!sq_db_key_mm) {
>  			ret = -ENOMEM;
>  			goto err_free_rq_key;
>  		}
> -		rq_db_key_mm = kmalloc(sizeof(*rq_db_key_mm),
> GFP_KERNEL);
> +		rq_db_key_mm = kzalloc(sizeof(*rq_db_key_mm),
> GFP_KERNEL);
>  		if (!rq_db_key_mm) {
>  			ret = -ENOMEM;
>  			goto err_free_sq_db_key;
>  		}
>  		if (t4_sq_onchip(&qhp->wq.sq)) {
> -			ma_sync_key_mm =
> kmalloc(sizeof(*ma_sync_key_mm),
> +			ma_sync_key_mm =
> kzalloc(sizeof(*ma_sync_key_mm),
>  						 GFP_KERNEL);
>  			if (!ma_sync_key_mm) {
>  				ret = -ENOMEM;
> diff --git a/drivers/infiniband/hw/cxgb4/resource.c
> b/drivers/infiniband/hw/cxgb4/resource.c
> index 3cf25997ed2b..166150f08351 100644
> --- a/drivers/infiniband/hw/cxgb4/resource.c
> +++ b/drivers/infiniband/hw/cxgb4/resource.c
> @@ -115,7 +115,7 @@ u32 c4iw_get_cqid(struct c4iw_rdev *rdev, struct
> c4iw_dev_ucontext *uctx)
>  		rdev->stats.qid.cur += rdev->qpmask + 1;
>  		mutex_unlock(&rdev->stats.lock);
>  		for (i = qid+1; i & rdev->qpmask; i++) {
> -			entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +			entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  			if (!entry)
>  				goto out;
>  			entry->qid = i;
> @@ -126,13 +126,13 @@ u32 c4iw_get_cqid(struct c4iw_rdev *rdev, struct
> c4iw_dev_ucontext *uctx)
>  		 * now put the same ids on the qp list since they all
>  		 * map to the same db/gts page.
>  		 */
> -		entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +		entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  		if (!entry)
>  			goto out;
>  		entry->qid = qid;
>  		list_add_tail(&entry->entry, &uctx->qpids);
>  		for (i = qid+1; i & rdev->qpmask; i++) {
> -			entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +			entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  			if (!entry)
>  				goto out;
>  			entry->qid = i;
> @@ -154,7 +154,7 @@ void c4iw_put_cqid(struct c4iw_rdev *rdev, u32 qid,
>  {
>  	struct c4iw_qid_list *entry;
> 
> -	entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +	entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  	if (!entry)
>  		return;
>  	pr_debug("qid 0x%x\n", qid);
> @@ -189,7 +189,7 @@ u32 c4iw_get_qpid(struct c4iw_rdev *rdev, struct
> c4iw_dev_ucontext *uctx)
>  		rdev->stats.qid.cur += rdev->qpmask + 1;
>  		mutex_unlock(&rdev->stats.lock);
>  		for (i = qid+1; i & rdev->qpmask; i++) {
> -			entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +			entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  			if (!entry)
>  				goto out;
>  			entry->qid = i;
> @@ -200,13 +200,13 @@ u32 c4iw_get_qpid(struct c4iw_rdev *rdev, struct
> c4iw_dev_ucontext *uctx)
>  		 * now put the same ids on the cq list since they all
>  		 * map to the same db/gts page.
>  		 */
> -		entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +		entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  		if (!entry)
>  			goto out;
>  		entry->qid = qid;
>  		list_add_tail(&entry->entry, &uctx->cqids);
>  		for (i = qid; i & rdev->qpmask; i++) {
> -			entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +			entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  			if (!entry)
>  				goto out;
>  			entry->qid = i;
> @@ -228,7 +228,7 @@ void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qid,
>  {
>  	struct c4iw_qid_list *entry;
> 
> -	entry = kmalloc(sizeof *entry, GFP_KERNEL);
> +	entry = kzalloc(sizeof *entry, GFP_KERNEL);
>  	if (!entry)
>  		return;
>  	pr_debug("qid 0x%x\n", qid);
> --
> 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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux