Skip to contentSkip to conversation

watchdog: sp5100_tco: Fix a memory leak of EFCH MMIO resource

PATCH In review Jean Delvare 2 participants 3 messages Jun 21, 2022 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: sp5100_tco: Fix a memory leak of EFCH MMIO resource

Unlike release_mem_region(), a call to release_resource() does not free the resource, so it has to be freed explicitly to avoid a memory leak.

Fixes 0578fff4aae5 ("Watchdog: sp5100_tco: Add initialization using EFCH MMIO")
Cc Terry Bowman <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>
---
 drivers/watchdog/sp5100_tco.c |    1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/sp5100_tco.c +1 -0
@@ -402,6 +402,7 @@ static int sp5100_tco_setupdevice_mmio(s
 		iounmap(addr);
 
 	release_resource(res);
+	kfree(res);
 
 	return ret;
 }
Signature · 2 lines
Jean Delvare
SUSE L3 Support
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jean Delvare

Unlike release_mem_region(), a call to release_resource() does not free the resource, so it has to be freed explicitly to avoid a memory leak.

Fixes 0578fff4aae5 ("Watchdog: sp5100_tco: Add initialization using EFCH MMIO")
Cc Terry Bowman <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>

Unless I am missing something, it looks like every caller of request_mem_region_muxed() has that problem.

Guenter

Quoted 19 lines
---
 drivers/watchdog/sp5100_tco.c |    1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/sp5100_tco.c +1 -0
@@ -402,6 +402,7 @@ static int sp5100_tco_setupdevice_mmio(s
 		iounmap(addr);
 
 	release_resource(res);
+	kfree(res);
 
 	return ret;
 }
Signature · 3 lines
-- 
Jean Delvare
SUSE L3 Support
#2 lore raw
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Jean Delvare

Unlike release_mem_region(), a call to release_resource() does not free the resource, so it has to be freed explicitly to avoid a memory leak.

Quoted 7 lines
Quoted 5 lines
Fixes 0578fff4aae5 ("Watchdog: sp5100_tco: Add initialization using EFCH MMIO")
Cc Terry Bowman <[email protected]>
Cc Wim Van Sebroeck <[email protected]>
Cc Guenter Roeck <[email protected]>

Thanks.

Quoted 2 lines

Unless I am missing something, it looks like every caller of request_mem_region_muxed() has that problem.

You are correct. Fixes have been sent for review already.

Signature · 2 lines
Jean Delvare
SUSE L3 Support