Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1600138

Re: [PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb

From Dan Carpenter <dan.carpenter@oracle.com>
Newsgroups linux.kernel
Subject Re: [PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb
Date 2017-03-14 10:10 +0100
Message-ID <tkQCR-6kd-19@gated-at.bofh.it> (permalink)
References <tkDFD-54Z-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Mar 13, 2017 at 07:14:08PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> On the error exit path, skb is always null, so the non-null check
> and __kfree_skb call are redundant.  Remove the redundant code,
> rename the rel_release label to err and make error paths jump to
> the err exit path.
> 
> Detected by CoverityScan, CID#114328 ("Logically Dead Code")
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
> index 1880eb6..f453a78 100644
> --- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
> +++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
> @@ -972,21 +972,21 @@ static int init_act_open(struct cxgbi_sock *csk)
>  			      &csk->daddr.sin_addr.s_addr);
>  	if (!csk->l2t) {
>  		pr_err("NO l2t available.\n");
> -		return -EINVAL;
> +		goto err;

err is a bad name because it doesn't say what the goto does.  Imagine
if function names were so opaque.  The most readable thing is a direct
return.

Also that's the least bug prone thing.

regards,
dan carpenter

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb Colin King <colin.king@canonical.com> - 2017-03-13 20:20 +0100
  Re: [PATCH] scsi: cxgb3i: remove redundant null check and kfree on  skb Dan Carpenter <dan.carpenter@oracle.com> - 2017-03-14 10:10 +0100

csiph-web