public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas A. Bellinger" <nab@risingtidesystems.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Roland Dreier <roland@kernel.org>,
	Sean Hefty <sean.hefty@intel.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>,
	linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org,
	target-devel <target-devel@vger.kernel.org>,
	Bart Van Assche <bart.vanassche@gmail.com>
Subject: Re: [patch 1/3] ib_srpt: fixup error handling in srpt_alloc_ioctx_ring()
Date: Fri, 04 Nov 2011 14:52:24 -0700	[thread overview]
Message-ID: <1320443544.5859.168.camel@haakon2.linux-iscsi.org> (raw)
In-Reply-To: <20111104182701.GG5796@elgon.mountain>

On Fri, 2011-11-04 at 21:27 +0300, Dan Carpenter wrote:
> We returned a freed value instead of NULL on certain error paths.
> Complicated error handling generally more error prone, so I've tried
> to simplify it a little by removing some gotos.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 

Looks like a reasonable cleanup.  Thanks Dan!

--nab

> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 1c29679..937b4bc 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -680,21 +680,20 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
>  
>  	ring = kmalloc(ring_size * sizeof(ring[0]), GFP_KERNEL);
>  	if (!ring)
> -		goto out;
> +		return NULL;
>  	for (i = 0; i < ring_size; ++i) {
>  		ring[i] = srpt_alloc_ioctx(sdev, ioctx_size, dma_size, dir);
>  		if (!ring[i])
>  			goto err;
>  		ring[i]->index = i;
>  	}
> -	goto out;
> +	return ring;
>  
>  err:
>  	while (--i >= 0)
>  		srpt_free_ioctx(sdev, ring[i], dma_size, dir);
>  	kfree(ring);
> -out:
> -	return ring;
> +	return NULL;
>  }
>  
>  /**

      reply	other threads:[~2011-11-04 21:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-04 18:27 [patch 1/3] ib_srpt: fixup error handling in srpt_alloc_ioctx_ring() Dan Carpenter
2011-11-04 21:52 ` Nicholas A. Bellinger [this message]

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=1320443544.5859.168.camel@haakon2.linux-iscsi.org \
    --to=nab@risingtidesystems.com \
    --cc=bart.vanassche@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=roland@kernel.org \
    --cc=sean.hefty@intel.com \
    --cc=target-devel@vger.kernel.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