usb: dwc3: qcom: Fix potential memory leak
Function dwc3_qcom_probe() allocates memory for resource structure
which is pointed by parent_res pointer. This memory is not
freed. This leads to memory leak. Use stack memory to prevent
memory leak.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 2bc02355f8
("usb: dwc3: qcom: Add support for booting with ACPI")
Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Link: https://lore.kernel.org/r/20230517172518.442591-1-VEfanov@ispras.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c722576b24
commit
097fb3ee71
|
@ -791,6 +791,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct dwc3_qcom *qcom;
|
struct dwc3_qcom *qcom;
|
||||||
struct resource *res, *parent_res = NULL;
|
struct resource *res, *parent_res = NULL;
|
||||||
|
struct resource local_res;
|
||||||
int ret, i;
|
int ret, i;
|
||||||
bool ignore_pipe_clk;
|
bool ignore_pipe_clk;
|
||||||
bool wakeup_source;
|
bool wakeup_source;
|
||||||
|
@ -842,9 +843,8 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
|
||||||
if (np) {
|
if (np) {
|
||||||
parent_res = res;
|
parent_res = res;
|
||||||
} else {
|
} else {
|
||||||
parent_res = kmemdup(res, sizeof(struct resource), GFP_KERNEL);
|
memcpy(&local_res, res, sizeof(struct resource));
|
||||||
if (!parent_res)
|
parent_res = &local_res;
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
parent_res->start = res->start +
|
parent_res->start = res->start +
|
||||||
qcom->acpi_pdata->qscratch_base_offset;
|
qcom->acpi_pdata->qscratch_base_offset;
|
||||||
|
|
Loading…
Reference in New Issue