Skip to content

Commit 9a39a92

Browse files
tititiou36holtmann
authored andcommitted
Bluetooth: btqcomsmd: Fix a resource leak in error handling paths in the probe function
Some resource should be released in the error handling path of the probe function, as already done in the remove function. The remove function was fixed in commit 5052de8 ("soc: qcom: smd: Transition client drivers from smd to rpmsg") Fixes: 1511cc7 ("Bluetooth: Introduce Qualcomm WCNSS SMD based HCI driver") Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 3db1a3f commit 9a39a92

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/bluetooth/btqcomsmd.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ static int btqcomsmd_probe(struct platform_device *pdev)
142142

143143
btq->cmd_channel = qcom_wcnss_open_channel(wcnss, "APPS_RIVA_BT_CMD",
144144
btqcomsmd_cmd_callback, btq);
145-
if (IS_ERR(btq->cmd_channel))
146-
return PTR_ERR(btq->cmd_channel);
145+
if (IS_ERR(btq->cmd_channel)) {
146+
ret = PTR_ERR(btq->cmd_channel);
147+
goto destroy_acl_channel;
148+
}
147149

148150
hdev = hci_alloc_dev();
149-
if (!hdev)
150-
return -ENOMEM;
151+
if (!hdev) {
152+
ret = -ENOMEM;
153+
goto destroy_cmd_channel;
154+
}
151155

152156
hci_set_drvdata(hdev, btq);
153157
btq->hdev = hdev;
@@ -161,14 +165,21 @@ static int btqcomsmd_probe(struct platform_device *pdev)
161165
hdev->set_bdaddr = qca_set_bdaddr_rome;
162166

163167
ret = hci_register_dev(hdev);
164-
if (ret < 0) {
165-
hci_free_dev(hdev);
166-
return ret;
167-
}
168+
if (ret < 0)
169+
goto hci_free_dev;
168170

169171
platform_set_drvdata(pdev, btq);
170172

171173
return 0;
174+
175+
hci_free_dev:
176+
hci_free_dev(hdev);
177+
destroy_cmd_channel:
178+
rpmsg_destroy_ept(btq->cmd_channel);
179+
destroy_acl_channel:
180+
rpmsg_destroy_ept(btq->acl_channel);
181+
182+
return ret;
172183
}
173184

174185
static int btqcomsmd_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)