[PATCH] media: cx25821: Fix a resource leak in cx25821_dev_setup()

Haoxiang Li posted 1 patch 1 month ago
drivers/media/pci/cx25821/cx25821-core.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] media: cx25821: Fix a resource leak in cx25821_dev_setup()
Posted by Haoxiang Li 1 month ago
Add release_mem_region() if ioremap() fails to release the memory
region obtained by cx25821_get_resources().

Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
 drivers/media/pci/cx25821/cx25821-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c
index 6627fa9166d3..a7336be44474 100644
--- a/drivers/media/pci/cx25821/cx25821-core.c
+++ b/drivers/media/pci/cx25821/cx25821-core.c
@@ -908,6 +908,7 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
 
 	if (!dev->lmmio) {
 		CX25821_ERR("ioremap failed, maybe increasing __VMALLOC_RESERVE in page.h\n");
+		release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0));
 		cx25821_iounmap(dev);
 		return -ENOMEM;
 	}
-- 
2.25.1
Re: [PATCH] media: cx25821: Fix a resource leak in cx25821_dev_setup()
Posted by Markus Elfring 1 month ago
> Add release_mem_region() if ioremap() fails to release the memory
> region obtained by cx25821_get_resources().

Do you try to synchronise resource release actions with information
from the implementation of the function “cx25821_dev_unregister”?
https://elixir.bootlin.com/linux/v6.19-rc3/source/drivers/media/pci/cx25821/cx25821-core.c#L939-L963

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.19-rc3#n145

Regards,
Markus