Commit addb3ffb authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Marcel Holtmann

Bluetooth: mediatek: Fix memory leak

In case memory resources for *fw* were allocated, release them before
return.

Addresses-Coverity-ID: 1472611 ("Resource leak")
Fixes: 7237c4c9 ("Bluetooth: mediatek: Add protocol support for MediaTek serial devices")
Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 51474eff
...@@ -144,8 +144,10 @@ static int mtk_setup_fw(struct hci_dev *hdev) ...@@ -144,8 +144,10 @@ static int mtk_setup_fw(struct hci_dev *hdev)
fw_size = fw->size; fw_size = fw->size;
/* The size of patch header is 30 bytes, should be skip */ /* The size of patch header is 30 bytes, should be skip */
if (fw_size < 30) if (fw_size < 30) {
return -EINVAL; err = -EINVAL;
goto free_fw;
}
fw_size -= 30; fw_size -= 30;
fw_ptr += 30; fw_ptr += 30;
...@@ -172,8 +174,8 @@ static int mtk_setup_fw(struct hci_dev *hdev) ...@@ -172,8 +174,8 @@ static int mtk_setup_fw(struct hci_dev *hdev)
fw_ptr += dlen; fw_ptr += dlen;
} }
free_fw:
release_firmware(fw); release_firmware(fw);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment