提交 247ea48b 编写于 作者: T Tomas Bortoli 提交者: Xie XiuQi

Bluetooth: Fix invalid-free in bcsp_close()

commit cf94da6f502d8caecabd56b194541c873c8a7a3c upstream.

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: NTomas Bortoli <tomasbortoli@gmail.com>
Reported-by: syzbot+a0d209a4676664613e76@syzkaller.appspotmail.com
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
Cc: Alexander Potapenko <glider@google.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 12f4b608
...@@ -606,6 +606,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count) ...@@ -606,6 +606,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
if (*ptr == 0xc0) { if (*ptr == 0xc0) {
BT_ERR("Short BCSP packet"); BT_ERR("Short BCSP packet");
kfree_skb(bcsp->rx_skb); kfree_skb(bcsp->rx_skb);
bcsp->rx_skb = NULL;
bcsp->rx_state = BCSP_W4_PKT_START; bcsp->rx_state = BCSP_W4_PKT_START;
bcsp->rx_count = 0; bcsp->rx_count = 0;
} else } else
...@@ -621,6 +622,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count) ...@@ -621,6 +622,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) { bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) {
BT_ERR("Error in BCSP hdr checksum"); BT_ERR("Error in BCSP hdr checksum");
kfree_skb(bcsp->rx_skb); kfree_skb(bcsp->rx_skb);
bcsp->rx_skb = NULL;
bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
bcsp->rx_count = 0; bcsp->rx_count = 0;
continue; continue;
...@@ -645,6 +647,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count) ...@@ -645,6 +647,7 @@ static int bcsp_recv(struct hci_uart *hu, const void *data, int count)
bscp_get_crc(bcsp)); bscp_get_crc(bcsp));
kfree_skb(bcsp->rx_skb); kfree_skb(bcsp->rx_skb);
bcsp->rx_skb = NULL;
bcsp->rx_state = BCSP_W4_PKT_DELIMITER; bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
bcsp->rx_count = 0; bcsp->rx_count = 0;
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册