diff mbox series

[13/13] USB: gadget: s3c2410_udc: fix memory leak with using debugfs_lookup()

Message ID 20230202153235.2412790-13-gregkh@linuxfoundation.org (mailing list archive)
State New, archived
Headers show
Series [01/13] USB: chipidea: fix memory leak with using debugfs_lookup() | expand

Commit Message

Greg KH Feb. 2, 2023, 3:32 p.m. UTC
When calling debugfs_lookup() the result must have dput() called on it,
otherwise the memory will leak over time.  To make things simpler, just
call debugfs_lookup_and_remove() instead which handles all of the logic
at once.

Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Jakob Koschel <jakobkoschel@gmail.com>
Cc: linux-usb@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/gadget/udc/s3c2410_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Feb. 3, 2023, 8:20 a.m. UTC | #1
On 02/02/2023 16:32, Greg Kroah-Hartman wrote:
> When calling debugfs_lookup() the result must have dput() called on it,
> otherwise the memory will leak over time.  To make things simpler, just
> call debugfs_lookup_and_remove() instead which handles all of the logic
> at once.
> 

Hi Greg,

This driver will be removed in v6.3 via Arnd's tree:
https://lore.kernel.org/all/20221021203329.4143397-13-arnd@kernel.org/

I think we can skip any work on this.

Best regards,
Krzysztof
Greg KH Feb. 6, 2023, 9:57 a.m. UTC | #2
On Fri, Feb 03, 2023 at 09:20:10AM +0100, Krzysztof Kozlowski wrote:
> On 02/02/2023 16:32, Greg Kroah-Hartman wrote:
> > When calling debugfs_lookup() the result must have dput() called on it,
> > otherwise the memory will leak over time.  To make things simpler, just
> > call debugfs_lookup_and_remove() instead which handles all of the logic
> > at once.
> > 
> 
> Hi Greg,
> 
> This driver will be removed in v6.3 via Arnd's tree:
> https://lore.kernel.org/all/20221021203329.4143397-13-arnd@kernel.org/
> 
> I think we can skip any work on this.

Ok, thanks, I'll drop it from my patch queue for now.  If it sticks
around, I'll apply it :)

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
index 8c57b191e52b..3525a3c260a7 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -1881,7 +1881,7 @@  static int s3c2410_udc_remove(struct platform_device *pdev)
 		return -EBUSY;
 
 	usb_del_gadget_udc(&udc->gadget);
-	debugfs_remove(debugfs_lookup("registers", s3c2410_udc_debugfs_root));
+	debugfs_lookup_and_remove("registers", s3c2410_udc_debugfs_root);
 
 	if (udc->vbus_gpiod)
 		free_irq(gpiod_to_irq(udc->vbus_gpiod), udc);