Bluetooth: Cleanup blkcipher on SMP termination
authorBrian Gix <bgix@codeaurora.org>
Wed, 23 Nov 2011 16:28:35 +0000 (08:28 -0800)
committerGustavo F. Padovan <padovan@profusion.mobi>
Thu, 1 Dec 2011 13:53:46 +0000 (22:53 +0900)
The blkcipher must be freed to avoid memory leak.

Signed-off-by: Brian Gix <bgix@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
net/bluetooth/smp.c

index 94e94ca353848768e5bca28c3364a7b8554acdf3..b9af4885ae53e4c60852133d38ab347edadfafca 100644 (file)
@@ -379,7 +379,15 @@ static struct smp_chan *smp_chan_create(struct l2cap_conn *conn)
 
 void smp_chan_destroy(struct l2cap_conn *conn)
 {
-       kfree(conn->smp_chan);
+       struct smp_chan *smp = conn->smp_chan;
+
+       clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->pend);
+
+       if (smp->tfm)
+               crypto_free_blkcipher(smp->tfm);
+
+       kfree(smp);
+       conn->smp_chan = NULL;
        hci_conn_put(conn->hcon);
 }