Skip to content

Commit 97a48da

Browse files
Yuuoniygregkh
authored andcommitted
usb: dwc3: qcom: Fix memory leak in dwc3_qcom_interconnect_init
of_icc_get() alloc resources for path handle, we should release it when not need anymore. Like the release in dwc3_qcom_interconnect_exit() function. Add icc_put() in error handling to fix this. Fixes: bea46b9 ("usb: dwc3: qcom: Add interconnect support in dwc3 driver") Cc: stable <stable@kernel.org> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Link: https://lore.kernel.org/r/20221206081731.818107-1-linmq006@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dc18a4c commit 97a48da

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/usb/dwc3/dwc3-qcom.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
261261
if (IS_ERR(qcom->icc_path_apps)) {
262262
dev_err(dev, "failed to get apps-usb path: %ld\n",
263263
PTR_ERR(qcom->icc_path_apps));
264-
return PTR_ERR(qcom->icc_path_apps);
264+
ret = PTR_ERR(qcom->icc_path_apps);
265+
goto put_path_ddr;
265266
}
266267

267268
max_speed = usb_get_maximum_speed(&qcom->dwc3->dev);
@@ -274,16 +275,22 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
274275
}
275276
if (ret) {
276277
dev_err(dev, "failed to set bandwidth for usb-ddr path: %d\n", ret);
277-
return ret;
278+
goto put_path_apps;
278279
}
279280

280281
ret = icc_set_bw(qcom->icc_path_apps, APPS_USB_AVG_BW, APPS_USB_PEAK_BW);
281282
if (ret) {
282283
dev_err(dev, "failed to set bandwidth for apps-usb path: %d\n", ret);
283-
return ret;
284+
goto put_path_apps;
284285
}
285286

286287
return 0;
288+
289+
put_path_apps:
290+
icc_put(qcom->icc_path_apps);
291+
put_path_ddr:
292+
icc_put(qcom->icc_path_ddr);
293+
return ret;
287294
}
288295

289296
/**

0 commit comments

Comments
 (0)