All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] "drivers:Fixed memory leak in /linux/drivers/tty/serial/8250/8250_lpss.c file.
@ 2024-04-26  2:19 lumingyindetect
  2024-04-26  9:06 ` Ilpo Järvinen
  2024-04-26 14:34 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: lumingyindetect @ 2024-04-26  2:19 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: ilpo.jarvinen, andriy.shevchenko, gregkh, jirislaby, LuMingYin

From: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>

In the lpss8250_probe function in the file /linux/drivers/tty/serial/8250/8250_lpss.c, there were certain return paths where pci_free_irq_vectors was not called to release memory related to pdev, leading to a memory leak. This commit fixes that issue."

Signed-off-by: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>
---
 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 776ec1ef29d6..2bb86f9cad5b 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 early_err_exit;
 
 	ret = lpss->board->setup(lpss, &uart.port);
 	if (ret)
-		return ret;
+		goto early_err_exit;
 
 	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);
+early_err_exit:
 	pci_free_irq_vectors(pdev);
 	return ret;
 }
-- 
2.25.1


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

* Re: [PATCH] "drivers:Fixed memory leak in /linux/drivers/tty/serial/8250/8250_lpss.c file.
  2024-04-26  2:19 [PATCH] "drivers:Fixed memory leak in /linux/drivers/tty/serial/8250/8250_lpss.c file lumingyindetect
@ 2024-04-26  9:06 ` Ilpo Järvinen
  2024-04-26 14:34 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2024-04-26  9:06 UTC (permalink / raw)
  To: lumingyindetect
  Cc: LKML, linux-serial, Andy Shevchenko, Greg Kroah-Hartman,
	Jiri Slaby, LuMingYin

On Fri, 26 Apr 2024, lumingyindetect@126.com wrote:

> From: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>

Use:

git log --oneline -- drivers/tty/serial/8250/8250_lpss.c

to learn what prefix you should use for shortlog (on the subject line). 
Beyond the correct prefix, don't use filename in the shortlog at all.

"Fixed" -> "Fix"

"in xx file" is awfully generic, please be more specific where the leak 
is.

> In the lpss8250_probe function in the file /linux/drivers/tty/serial/8250/8250_lpss.c, there were certain return paths where pci_free_irq_vectors was not called to release memory related to pdev, leading to a memory leak. This commit fixes that issue." 

- Wrap this properly.
- Don't write full paths like that.
- Put () into description when talking about functions.
- Use imperative language, don't use "This patch ...".

- Add Fixes tag

> Signed-off-by: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>

> ---
>  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 776ec1ef29d6..2bb86f9cad5b 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 early_err_exit;
>  
>  	ret = lpss->board->setup(lpss, &uart.port);
>  	if (ret)
> -		return ret;
> +		goto early_err_exit;
>  
>  	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);
> +early_err_exit:

This label could be more specific that it's about freeing the vectors.

>  	pci_free_irq_vectors(pdev);
>  	return ret;
>  }
> 

-- 
 i.


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

* Re: [PATCH] "drivers:Fixed memory leak in /linux/drivers/tty/serial/8250/8250_lpss.c file.
  2024-04-26  2:19 [PATCH] "drivers:Fixed memory leak in /linux/drivers/tty/serial/8250/8250_lpss.c file lumingyindetect
  2024-04-26  9:06 ` Ilpo Järvinen
@ 2024-04-26 14:34 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-04-26 14:34 UTC (permalink / raw)
  To: lumingyindetect
  Cc: linux-kernel, linux-serial, ilpo.jarvinen, gregkh, jirislaby,
	LuMingYin

On Fri, Apr 26, 2024 at 03:19:39AM +0100, lumingyindetect@126.com wrote:
> From: LuMingYin <11570291+yin-luming@user.noreply.gitee.com>
> 
> In the lpss8250_probe function in the file
> /linux/drivers/tty/serial/8250/8250_lpss.c, there were certain return paths
> where pci_free_irq_vectors was not called to release memory related to pdev,
> leading to a memory leak. This commit fixes that issue."

This patch does not fix anything. The driver uses pcim_enable_device()
which changes how this all behaves.

NAK.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-04-26 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26  2:19 [PATCH] "drivers:Fixed memory leak in /linux/drivers/tty/serial/8250/8250_lpss.c file lumingyindetect
2024-04-26  9:06 ` Ilpo Järvinen
2024-04-26 14:34 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.