Patch "usb: dwc3: qcom: Fix potential memory leak" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: dwc3: qcom: Fix potential memory leak

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-dwc3-qcom-fix-potential-memory-leak.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0d77c20807fb276e36370300c4c66cda0f328b23
Author: Vladislav Efanov <VEfanov@xxxxxxxxx>
Date:   Wed May 17 20:25:18 2023 +0300

    usb: dwc3: qcom: Fix potential memory leak
    
    [ Upstream commit 097fb3ee710d4de83b8d4f5589e8ee13e0f0541e ]
    
    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: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI")
    Signed-off-by: Vladislav Efanov <VEfanov@xxxxxxxxx>
    Acked-by: Shawn Guo <shawn.guo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230517172518.442591-1-VEfanov@xxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 2dcdeb52fc293..7d3de23147fd5 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -574,6 +574,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	struct device		*dev = &pdev->dev;
 	struct dwc3_qcom	*qcom;
 	struct resource		*res, *parent_res = NULL;
+	struct resource		local_res;
 	int			ret, i;
 	bool			ignore_pipe_clk;
 
@@ -624,9 +625,8 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	if (np) {
 		parent_res = res;
 	} else {
-		parent_res = kmemdup(res, sizeof(struct resource), GFP_KERNEL);
-		if (!parent_res)
-			return -ENOMEM;
+		memcpy(&local_res, res, sizeof(struct resource));
+		parent_res = &local_res;
 
 		parent_res->start = res->start +
 			qcom->acpi_pdata->qscratch_base_offset;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux