linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup()
       [not found] <20230202153235.2412790-1-gregkh@linuxfoundation.org>
@ 2023-02-02 15:32 ` Greg Kroah-Hartman
  2023-02-02 16:24   ` Vladimir Zapolskiy
  2023-02-02 15:32 ` [PATCH 11/13] USB: gadget: pxa25x_udc: " Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 15:32 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Vladimir Zapolskiy, Jakob Koschel,
	Miaoqian Lin, linux-arm-kernel, linux-kernel

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: Vladimir Zapolskiy <vz@mleia.com>
Cc: Jakob Koschel <jakobkoschel@gmail.com>
Cc: Miaoqian Lin <linmq006@gmail.com>
Cc: linux-usb@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/gadget/udc/lpc32xx_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c
index cea10cdb83ae..fe62db32dd0e 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -532,7 +532,7 @@ static void create_debug_file(struct lpc32xx_udc *udc)
 
 static void remove_debug_file(struct lpc32xx_udc *udc)
 {
-	debugfs_remove(debugfs_lookup(debug_filename, NULL));
+	debugfs_lookup_and_remove(debug_filename, NULL);
 }
 
 #else
-- 
2.39.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 11/13] USB: gadget: pxa25x_udc: fix memory leak with using debugfs_lookup()
       [not found] <20230202153235.2412790-1-gregkh@linuxfoundation.org>
  2023-02-02 15:32 ` [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
@ 2023-02-02 15:32 ` Greg Kroah-Hartman
  2023-02-02 15:32 ` [PATCH 12/13] USB: gadget: pxa27x_udc: " Greg Kroah-Hartman
  2023-02-02 15:32 ` [PATCH 13/13] USB: gadget: s3c2410_udc: " Greg Kroah-Hartman
  3 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 15:32 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	linux-arm-kernel, linux-kernel

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: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/gadget/udc/pxa25x_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
index c593fc383481..9e01ddf2b417 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -1340,7 +1340,7 @@ DEFINE_SHOW_ATTRIBUTE(udc_debug);
 		debugfs_create_file(dev->gadget.name, \
 			S_IRUGO, NULL, dev, &udc_debug_fops); \
 	} while (0)
-#define remove_debug_files(dev) debugfs_remove(debugfs_lookup(dev->gadget.name, NULL))
+#define remove_debug_files(dev) debugfs_lookup_and_remove(dev->gadget.name, NULL)
 
 #else	/* !CONFIG_USB_GADGET_DEBUG_FILES */
 
-- 
2.39.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 12/13] USB: gadget: pxa27x_udc: fix memory leak with using debugfs_lookup()
       [not found] <20230202153235.2412790-1-gregkh@linuxfoundation.org>
  2023-02-02 15:32 ` [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
  2023-02-02 15:32 ` [PATCH 11/13] USB: gadget: pxa25x_udc: " Greg Kroah-Hartman
@ 2023-02-02 15:32 ` Greg Kroah-Hartman
  2023-02-02 15:32 ` [PATCH 13/13] USB: gadget: s3c2410_udc: " Greg Kroah-Hartman
  3 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 15:32 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Daniel Mack, Haojian Zhuang, Robert Jarzmik,
	linux-arm-kernel, linux-kernel

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: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index ac980d6a4740..0ecdfd2ba9e9 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -215,7 +215,7 @@ static void pxa_init_debugfs(struct pxa_udc *udc)
 
 static void pxa_cleanup_debugfs(struct pxa_udc *udc)
 {
-	debugfs_remove(debugfs_lookup(udc->gadget.name, usb_debug_root));
+	debugfs_lookup_and_remove(udc->gadget.name, usb_debug_root);
 }
 
 #else
-- 
2.39.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 13/13] USB: gadget: s3c2410_udc: fix memory leak with using debugfs_lookup()
       [not found] <20230202153235.2412790-1-gregkh@linuxfoundation.org>
                   ` (2 preceding siblings ...)
  2023-02-02 15:32 ` [PATCH 12/13] USB: gadget: pxa27x_udc: " Greg Kroah-Hartman
@ 2023-02-02 15:32 ` Greg Kroah-Hartman
  2023-02-03  8:20   ` Krzysztof Kozlowski
  3 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-02 15:32 UTC (permalink / raw)
  To: linux-usb
  Cc: Greg Kroah-Hartman, Krzysztof Kozlowski, Alim Akhtar,
	Linus Walleij, Jakob Koschel, linux-arm-kernel, linux-samsung-soc,
	linux-kernel

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(-)

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);
-- 
2.39.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup()
  2023-02-02 15:32 ` [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
@ 2023-02-02 16:24   ` Vladimir Zapolskiy
  0 siblings, 0 replies; 7+ messages in thread
From: Vladimir Zapolskiy @ 2023-02-02 16:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb
  Cc: Jakob Koschel, Miaoqian Lin, linux-arm-kernel, linux-kernel

On 2/2/23 17: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.
> 
> Cc: Vladimir Zapolskiy <vz@mleia.com>
> Cc: Jakob Koschel <jakobkoschel@gmail.com>
> Cc: Miaoqian Lin <linmq006@gmail.com>
> Cc: linux-usb@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---

Acked-by: Vladimir Zapolskiy <vz@mleia.com>

--
Best wishes,
Vladimir

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 13/13] USB: gadget: s3c2410_udc: fix memory leak with using debugfs_lookup()
  2023-02-02 15:32 ` [PATCH 13/13] USB: gadget: s3c2410_udc: " Greg Kroah-Hartman
@ 2023-02-03  8:20   ` Krzysztof Kozlowski
  2023-02-06  9:57     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-02-03  8:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-usb
  Cc: Alim Akhtar, Linus Walleij, Jakob Koschel, linux-arm-kernel,
	linux-samsung-soc, linux-kernel, Arnd Bergmann

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 13/13] USB: gadget: s3c2410_udc: fix memory leak with using debugfs_lookup()
  2023-02-03  8:20   ` Krzysztof Kozlowski
@ 2023-02-06  9:57     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2023-02-06  9:57 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: linux-usb, Alim Akhtar, Linus Walleij, Jakob Koschel,
	linux-arm-kernel, linux-samsung-soc, linux-kernel, Arnd Bergmann

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-06  9:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230202153235.2412790-1-gregkh@linuxfoundation.org>
2023-02-02 15:32 ` [PATCH 10/13] USB: gadget: lpc32xx_udc: fix memory leak with using debugfs_lookup() Greg Kroah-Hartman
2023-02-02 16:24   ` Vladimir Zapolskiy
2023-02-02 15:32 ` [PATCH 11/13] USB: gadget: pxa25x_udc: " Greg Kroah-Hartman
2023-02-02 15:32 ` [PATCH 12/13] USB: gadget: pxa27x_udc: " Greg Kroah-Hartman
2023-02-02 15:32 ` [PATCH 13/13] USB: gadget: s3c2410_udc: " Greg Kroah-Hartman
2023-02-03  8:20   ` Krzysztof Kozlowski
2023-02-06  9:57     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).