Skip to content

Commit 56f6de3

Browse files
Yuuoniygregkh
authored andcommitted
usb: dwc3: qcom: Fix memory leak in dwc3_qcom_interconnect_init
[ Upstream commit 97a48da ] 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 <[email protected]> Acked-by: Thinh Nguyen <[email protected]> Signed-off-by: Miaoqian Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 90ffbb7 commit 56f6de3

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
@@ -258,7 +258,8 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
258258
if (IS_ERR(qcom->icc_path_apps)) {
259259
dev_err(dev, "failed to get apps-usb path: %ld\n",
260260
PTR_ERR(qcom->icc_path_apps));
261-
return PTR_ERR(qcom->icc_path_apps);
261+
ret = PTR_ERR(qcom->icc_path_apps);
262+
goto put_path_ddr;
262263
}
263264

264265
if (usb_get_maximum_speed(&qcom->dwc3->dev) >= USB_SPEED_SUPER ||
@@ -271,17 +272,23 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom)
271272

272273
if (ret) {
273274
dev_err(dev, "failed to set bandwidth for usb-ddr path: %d\n", ret);
274-
return ret;
275+
goto put_path_apps;
275276
}
276277

277278
ret = icc_set_bw(qcom->icc_path_apps,
278279
APPS_USB_AVG_BW, APPS_USB_PEAK_BW);
279280
if (ret) {
280281
dev_err(dev, "failed to set bandwidth for apps-usb path: %d\n", ret);
281-
return ret;
282+
goto put_path_apps;
282283
}
283284

284285
return 0;
286+
287+
put_path_apps:
288+
icc_put(qcom->icc_path_apps);
289+
put_path_ddr:
290+
icc_put(qcom->icc_path_ddr);
291+
return ret;
285292
}
286293

287294
/**

0 commit comments

Comments
 (0)