public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Max Gurtovoy <maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: bvanassche-HInyCGIudOg@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	israelr-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
Subject: Re: [PATCH 2/3] IB/srpt: allocate ib_qp_attr on the stack
Date: Wed, 28 Dec 2016 14:57:56 +0200	[thread overview]
Message-ID: <20161228125756.GG26885@mtr-leonro.local> (raw)
In-Reply-To: <1482922813-8392-3-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1805 bytes --]

On Wed, Dec 28, 2016 at 01:00:12PM +0200, Max Gurtovoy wrote:
> No reason to allocate it dynamically.
>
> Signed-off-by: Max Gurtovoy <maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c |   18 +++++++-----------
>  1 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 0b1f69e..aa18d74 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -984,24 +984,20 @@ static int srpt_get_desc_tbl(struct srpt_send_ioctx *ioctx,
>   */
>  static int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp)
>  {
> -	struct ib_qp_attr *attr;
> +	struct ib_qp_attr attr;
>  	int ret;
>
> -	attr = kzalloc(sizeof(*attr), GFP_KERNEL);
> -	if (!attr)
> -		return -ENOMEM;
> -
> -	attr->qp_state = IB_QPS_INIT;
> -	attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ |
> +	memset(&attr, 0, sizeof(attr));

This line will not needed if you initialize to zero this struct attr at the beginning of function.


> +	attr.qp_state = IB_QPS_INIT;
> +	attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_READ |
>  	    IB_ACCESS_REMOTE_WRITE;
> -	attr->port_num = ch->sport->port;
> -	attr->pkey_index = 0;
> +	attr.port_num = ch->sport->port;
> +	attr.pkey_index = 0;
>
> -	ret = ib_modify_qp(qp, attr,
> +	ret = ib_modify_qp(qp, &attr,
>  			   IB_QP_STATE | IB_QP_ACCESS_FLAGS | IB_QP_PORT |
>  			   IB_QP_PKEY_INDEX);
>
> -	kfree(attr);
>  	return ret;
>  }
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2016-12-28 12:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-28 11:00 [PATCH 0/3] srp/srpt - some useful patches Max Gurtovoy
     [not found] ` <1482922813-8392-1-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-12-28 11:00   ` [PATCH 1/3] IB/srp: allocate ib_qp_attr on the stack Max Gurtovoy
     [not found]     ` <1482922813-8392-2-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-12-28 11:14       ` Yuval Shaia
2016-12-28 11:33         ` Max Gurtovoy
2016-12-28 11:38       ` Bart Van Assche
2016-12-28 11:00   ` [PATCH 2/3] IB/srpt: " Max Gurtovoy
     [not found]     ` <1482922813-8392-3-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-12-28 11:06       ` Yuval Shaia
2016-12-28 11:38         ` Max Gurtovoy
2016-12-28 11:39       ` Bart Van Assche
2016-12-28 12:57       ` Leon Romanovsky [this message]
2016-12-28 11:00   ` [PATCH 3/3] IB/srpt: fix compilation warning Max Gurtovoy
     [not found]     ` <1482922813-8392-4-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-12-28 11:18       ` Yuval Shaia
2016-12-28 11:41       ` Bart Van Assche
     [not found]         ` <1482925264.6713.5.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-12-28 11:44           ` Max Gurtovoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161228125756.GG26885@mtr-leonro.local \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=bvanassche-HInyCGIudOg@public.gmane.org \
    --cc=israelr-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox