Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btmtkuart: fix error handling in mtk_hci_wmt_sync()

This code has an uninitialized variable warning:

drivers/bluetooth/btmtkuart.c:184 mtk_hci_wmt_sync()
error: uninitialized symbol 'wc'.

But it also has error paths which have memory leaks.

Fixes: 8f550f55b155 ("Bluetooth: btmtkuart: rely on BT_MTK module")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Dan Carpenter and committed by
Marcel Holtmann
a76d269a 9fa6b4cd

+7 -5
+7 -5
drivers/bluetooth/btmtkuart.c
··· 105 105 } 106 106 107 107 wc = kzalloc(hlen, GFP_KERNEL); 108 - if (!wc) 109 - return -ENOMEM; 108 + if (!wc) { 109 + err = -ENOMEM; 110 + goto err_free_skb; 111 + } 110 112 111 113 hdr = &wc->hdr; 112 114 hdr->dir = 1; ··· 155 153 bt_dev_err(hdev, "Wrong op received %d expected %d", 156 154 wmt_evt->whdr.op, hdr->op); 157 155 err = -EIO; 158 - goto err_free_skb; 156 + goto err_free_wc; 159 157 } 160 158 161 159 switch (wmt_evt->whdr.op) { ··· 179 177 if (wmt_params->status) 180 178 *wmt_params->status = status; 181 179 180 + err_free_wc: 181 + kfree(wc); 182 182 err_free_skb: 183 183 kfree_skb(bdev->evt_skb); 184 184 bdev->evt_skb = NULL; 185 - err_free_wc: 186 - kfree(wc); 187 185 188 186 return err; 189 187 }