2024-04-26 13:41:36

by lumingyindetect

[permalink] [raw]
Subject: [PATCH] serial: 8250_lpss: Fix memory leak in lpss8250_probe()

From: LuMingYin <[email protected]>

The return statements at line 347 and line 351 in the lpss8250_probe() function result in a memory leak of the variable pdev.
Add a label named free_irq_vectors in the lpss8250_probe() function to release the memory area pointed to by pdev.
Modify the two return statements mentioned above to jump to the label "free_irq_vectors" instead.

Fixes: e88c4cfcb7b888ac374916806f86c17d8ecaeb67 ("serial: 8250_lpss: fix memory in lpss8250_probe()")

Signed-off-by: LuMingYin <[email protected]>
---
drivers/tty/serial/8250/8250_lpss.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index c3cd6cb9ac80..fa9fd4dc86c7 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -344,11 +344,11 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
uart.port.mapbase = pci_resource_start(pdev, 0);
uart.port.membase = pcim_iomap(pdev, 0, 0);
if (!uart.port.membase)
- return -ENOMEM;
+ goto free_irq_vectors;

ret = lpss->board->setup(lpss, &uart.port);
if (ret)
- return ret;
+ goto free_irq_vectors;

dw8250_setup_port(&uart.port);

@@ -367,6 +367,7 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)

err_exit:
lpss->board->exit(lpss);
+free_irq_vectors:
pci_free_irq_vectors(pdev);
return ret;
}
--
2.25.1



2024-04-26 13:59:28

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] serial: 8250_lpss: Fix memory leak in lpss8250_probe()

On Fri, Apr 26, 2024 at 02:39:59PM +0100, [email protected] wrote:
> From: LuMingYin <[email protected]>
>
> The return statements at line 347 and line 351 in the lpss8250_probe() function result in a memory leak of the variable pdev.
> Add a label named free_irq_vectors in the lpss8250_probe() function to release the memory area pointed to by pdev.
> Modify the two return statements mentioned above to jump to the label "free_irq_vectors" instead.
>
> Fixes: e88c4cfcb7b888ac374916806f86c17d8ecaeb67 ("serial: 8250_lpss: fix memory in lpss8250_probe()")
>
> Signed-off-by: LuMingYin <[email protected]>

Please stop and read all of the instructions provide, and then go read
the "how to submit your first patch" tutorial at kernelnewbies.org and
compare that to what you have been sending here.

You also keep sending stuff to quickly, patches should be, at the most,
sent once a day, and even then, that would be very quick.

Relax, take the weekend off, and come back next week with a proper
change based on the documentation.

thanks,

greg k-h

2024-04-26 14:45:02

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] serial: 8250_lpss: Fix memory leak in lpss8250_probe()

On Fri, Apr 26, 2024 at 02:39:59PM +0100, [email protected] wrote:
> From: LuMingYin <[email protected]>
>
> The return statements at line 347 and line 351 in the lpss8250_probe()
> function result in a memory leak of the variable pdev. Add a label named
> free_irq_vectors in the lpss8250_probe() function to release the memory area
> pointed to by pdev. Modify the two return statements mentioned above to jump
> to the label "free_irq_vectors" instead.

> Fixes: e88c4cfcb7b888ac374916806f86c17d8ecaeb67 ("serial: 8250_lpss: fix memory in lpss8250_probe()")

Same as for the previous version, NAK.

This patch does NOT fix anything. Please, read the code and try to understand
how it works.

--
With Best Regards,
Andy Shevchenko



2024-04-26 17:57:52

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH] serial: 8250_lpss: Fix memory leak in lpss8250_probe()

On Fri, 26 Apr 2024, [email protected] wrote:

> From: LuMingYin <[email protected]>
>
> The return statements at line 347 and line 351 in the lpss8250_probe() function result in a memory leak of the variable pdev.
> Add a label named free_irq_vectors in the lpss8250_probe() function to release the memory area pointed to by pdev.
> Modify the two return statements mentioned above to jump to the label "free_irq_vectors" instead.

Also, this is not a 100m sprint. Please leave time for people to comment
on your previous submission before sending the next version out.

People are from different timezones and have other things to look too
besides your patch so they might not be happy if they find 4 versions of
your patch in their inbox before even having time to look at the first
one.

--
i.