Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63511f6d authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg
Browse files

Bluetooth: Fix potential NULL dereference in SMP channel setup



When the allocation of the L2CAP channel for the BR/EDR security manager
fails, then the smp variable might be NULL. In that case do not try to
free the non-existing crypto contexts

Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 19c5ce9c
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -3124,9 +3124,11 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)
create_chan:
	chan = l2cap_chan_create();
	if (!chan) {
		if (smp) {
			crypto_free_blkcipher(smp->tfm_aes);
			crypto_free_hash(smp->tfm_cmac);
			kzfree(smp);
		}
		return ERR_PTR(-ENOMEM);
	}