Skip to content

Commit cf94da6

Browse files
Tomas Bortoliholtmann
authored andcommitted
Bluetooth: Fix invalid-free in bcsp_close()
Syzbot reported an invalid-free that I introduced fixing a memleak. bcsp_recv() also frees bcsp->rx_skb but never nullifies its value. Nullify bcsp->rx_skb every time it is freed. Signed-off-by: Tomas Bortoli <[email protected]> Reported-by: [email protected] Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 41d5b25 commit cf94da6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/bluetooth/hci_bcsp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
591591
if (*ptr == 0xc0) {
592592
BT_ERR("Short BCSP packet");
593593
kfree_skb(bcsp->rx_skb);
594+
bcsp->rx_skb = NULL;
594595
bcsp->rx_state = BCSP_W4_PKT_START;
595596
bcsp->rx_count = 0;
596597
} else
@@ -606,6 +607,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
606607
bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) {
607608
BT_ERR("Error in BCSP hdr checksum");
608609
kfree_skb(bcsp->rx_skb);
610+
bcsp->rx_skb = NULL;
609611
bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
610612
bcsp->rx_count = 0;
611613
continue;
@@ -630,6 +632,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
630632
bscp_get_crc(bcsp));
631633

632634
kfree_skb(bcsp->rx_skb);
635+
bcsp->rx_skb = NULL;
633636
bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
634637
bcsp->rx_count = 0;
635638
continue;

0 commit comments

Comments
 (0)