Skip to content

Commit a368a6e

Browse files
vinaychelsiogregkh
authored andcommitted
chelsio/chtls: fix memory leaks in CPL handlers
[ Upstream commit 6daa1da ] CPL handler functions chtls_pass_open_rpl() and chtls_close_listsrv_rpl() should return CPL_RET_BUF_DONE so that caller function will do skb free to avoid leak. Fixes: cc35c88 ("crypto : chtls - CPL handler definition") Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com> Link: https://lore.kernel.org/r/20201025194228.31271-1-vinay.yadav@chelsio.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6e3163c commit a368a6e

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

drivers/crypto/chelsio/chtls/chtls_cm.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -772,14 +772,13 @@ static int chtls_pass_open_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
772772
if (rpl->status != CPL_ERR_NONE) {
773773
pr_info("Unexpected PASS_OPEN_RPL status %u for STID %u\n",
774774
rpl->status, stid);
775-
return CPL_RET_BUF_DONE;
775+
} else {
776+
cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
777+
sock_put(listen_ctx->lsk);
778+
kfree(listen_ctx);
779+
module_put(THIS_MODULE);
776780
}
777-
cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
778-
sock_put(listen_ctx->lsk);
779-
kfree(listen_ctx);
780-
module_put(THIS_MODULE);
781-
782-
return 0;
781+
return CPL_RET_BUF_DONE;
783782
}
784783

785784
static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
@@ -796,15 +795,13 @@ static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
796795
if (rpl->status != CPL_ERR_NONE) {
797796
pr_info("Unexpected CLOSE_LISTSRV_RPL status %u for STID %u\n",
798797
rpl->status, stid);
799-
return CPL_RET_BUF_DONE;
798+
} else {
799+
cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
800+
sock_put(listen_ctx->lsk);
801+
kfree(listen_ctx);
802+
module_put(THIS_MODULE);
800803
}
801-
802-
cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
803-
sock_put(listen_ctx->lsk);
804-
kfree(listen_ctx);
805-
module_put(THIS_MODULE);
806-
807-
return 0;
804+
return CPL_RET_BUF_DONE;
808805
}
809806

810807
static void chtls_purge_wr_queue(struct sock *sk)

0 commit comments

Comments
 (0)