]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
chelsio/chtls: fix a double free in chtls_setkey()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 3 Dec 2020 08:44:31 +0000 (11:44 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Dec 2020 09:18:54 +0000 (10:18 +0100)
[ Upstream commit 391119fb5c5c4bdb4d57c7ffeb5e8d18560783d1 ]

The "skb" is freed by the transmit code in cxgb4_ofld_send() and we
shouldn't use it again.  But in the current code, if we hit an error
later on in the function then the clean up code will call kfree_skb(skb)
and so it causes a double free.

Set the "skb" to NULL and that makes the kfree_skb() a no-op.

Fixes: d25f2f71f653 ("crypto: chtls - Program the TLS session Key")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X8ilb6PtBRLWiSHp@mwanda
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/chelsio/chtls/chtls_hw.c

index 2294fb06bef369ecf0584652070e04df68e962cf..7ea9dcfd7c4923157f9a29b298f9dcea50fd5557 100644 (file)
@@ -376,6 +376,7 @@ int chtls_setkey(struct chtls_sock *csk, u32 keylen, u32 optname)
        csk->wr_unacked += DIV_ROUND_UP(len, 16);
        enqueue_wr(csk, skb);
        cxgb4_ofld_send(csk->egress_dev, skb);
+       skb = NULL;
 
        chtls_set_scmd(csk);
        /* Clear quiesce for Rx key */