Skip to content

Commit b6170a4

Browse files
Dan Carpentermartinkpetersen
authored andcommitted
scsi: cxgb3i: Fix some leaks in init_act_open()
There wasn't any clean up done if cxgb3_alloc_atid() failed and also the original code didn't release "csk->l2t". Link: https://lore.kernel.org/r/20200521121221.GA247492@mwanda Fixes: 6f7efaa ("[SCSI] cxgb3i: change cxgb3i to use libcxgbi") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 1f93ad1 commit b6170a4

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

drivers/scsi/cxgbi/cxgb3i/cxgb3i.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ static int init_act_open(struct cxgbi_sock *csk)
959959
struct net_device *ndev = cdev->ports[csk->port_id];
960960
struct cxgbi_hba *chba = cdev->hbas[csk->port_id];
961961
struct sk_buff *skb = NULL;
962+
int ret;
962963

963964
log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
964965
"csk 0x%p,%u,0x%lx.\n", csk, csk->state, csk->flags);
@@ -979,16 +980,16 @@ static int init_act_open(struct cxgbi_sock *csk)
979980
csk->atid = cxgb3_alloc_atid(t3dev, &t3_client, csk);
980981
if (csk->atid < 0) {
981982
pr_err("NO atid available.\n");
982-
return -EINVAL;
983+
ret = -EINVAL;
984+
goto put_sock;
983985
}
984986
cxgbi_sock_set_flag(csk, CTPF_HAS_ATID);
985987
cxgbi_sock_get(csk);
986988

987989
skb = alloc_wr(sizeof(struct cpl_act_open_req), 0, GFP_KERNEL);
988990
if (!skb) {
989-
cxgb3_free_atid(t3dev, csk->atid);
990-
cxgbi_sock_put(csk);
991-
return -ENOMEM;
991+
ret = -ENOMEM;
992+
goto free_atid;
992993
}
993994
skb->sk = (struct sock *)csk;
994995
set_arp_failure_handler(skb, act_open_arp_failure);
@@ -1010,6 +1011,15 @@ static int init_act_open(struct cxgbi_sock *csk)
10101011
cxgbi_sock_set_state(csk, CTP_ACTIVE_OPEN);
10111012
send_act_open_req(csk, skb, csk->l2t);
10121013
return 0;
1014+
1015+
free_atid:
1016+
cxgb3_free_atid(t3dev, csk->atid);
1017+
put_sock:
1018+
cxgbi_sock_put(csk);
1019+
l2t_release(t3dev, csk->l2t);
1020+
csk->l2t = NULL;
1021+
1022+
return ret;
10131023
}
10141024

10151025
cxgb3_cpl_handler_func cxgb3i_cpl_handlers[NUM_CPL_CMDS] = {

0 commit comments

Comments
 (0)