* [PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb
@ 2017-03-13 19:14 Colin King
2017-03-14 9:08 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-03-13 19:14 UTC (permalink / raw)
To: Karen Xie, James E . J . Bottomley, Martin K . Petersen,
linux-scsi
Cc: kernel-janitors, linux-kernel
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;
}
cxgbi_sock_get(csk);
csk->atid = cxgb3_alloc_atid(t3dev, &t3_client, csk);
if (csk->atid < 0) {
pr_err("NO atid available.\n");
- goto rel_resource;
+ goto err;
}
cxgbi_sock_set_flag(csk, CTPF_HAS_ATID);
cxgbi_sock_get(csk);
skb = alloc_wr(sizeof(struct cpl_act_open_req), 0, GFP_KERNEL);
if (!skb)
- goto rel_resource;
+ goto err;
skb->sk = (struct sock *)csk;
set_arp_failure_handler(skb, act_open_arp_failure);
csk->snd_win = cxgb3i_snd_win;
@@ -1008,9 +1008,7 @@ static int init_act_open(struct cxgbi_sock *csk)
send_act_open_req(csk, skb, csk->l2t);
return 0;
-rel_resource:
- if (skb)
- __kfree_skb(skb);
+err:
return -EINVAL;
}
--
2.10.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb
2017-03-13 19:14 [PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb Colin King
@ 2017-03-14 9:08 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2017-03-14 9:08 UTC (permalink / raw)
To: Colin King
Cc: Karen Xie, James E . J . Bottomley, Martin K . Petersen,
linux-scsi, kernel-janitors, linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-14 9:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 19:14 [PATCH] scsi: cxgb3i: remove redundant null check and kfree on skb Colin King
2017-03-14 9:08 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).