Message ID | 20220621152840.420a0f4c@endymion.delvare (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | watchdog: sp5100_tco: Fix a memory leak of EFCH MMIO resource | expand |
On Tue, Jun 21, 2022 at 03:28:40PM +0200, Jean Delvare wrote: > 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. > > Signed-off-by: Jean Delvare <jdelvare@suse.de> > Fixes: 0578fff4aae5 ("Watchdog: sp5100_tco: Add initialization using EFCH MMIO") > Cc: Terry Bowman <terry.bowman@amd.com> > Cc: Wim Van Sebroeck <wim@linux-watchdog.org> > Cc: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Unless I am missing something, it looks like every caller of request_mem_region_muxed() has that problem. Guenter > --- > drivers/watchdog/sp5100_tco.c | 1 + > 1 file changed, 1 insertion(+) > > --- linux-5.18.orig/drivers/watchdog/sp5100_tco.c 2022-05-22 21:52:31.000000000 +0200 > +++ linux-5.18/drivers/watchdog/sp5100_tco.c 2022-06-21 15:07:31.868814828 +0200 > @@ -402,6 +402,7 @@ static int sp5100_tco_setupdevice_mmio(s > iounmap(addr); > > release_resource(res); > + kfree(res); > > return ret; > } > > > -- > Jean Delvare > SUSE L3 Support
On Tue, 21 Jun 2022 07:08:25 -0700, Guenter Roeck wrote: > On Tue, Jun 21, 2022 at 03:28:40PM +0200, Jean Delvare wrote: > > 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. > > > > Signed-off-by: Jean Delvare <jdelvare@suse.de> > > Fixes: 0578fff4aae5 ("Watchdog: sp5100_tco: Add initialization using EFCH MMIO") > > Cc: Terry Bowman <terry.bowman@amd.com> > > Cc: Wim Van Sebroeck <wim@linux-watchdog.org> > > Cc: Guenter Roeck <linux@roeck-us.net> > > Reviewed-by: Guenter Roeck <linux@roeck-us.net> Thanks. > 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.
--- linux-5.18.orig/drivers/watchdog/sp5100_tco.c 2022-05-22 21:52:31.000000000 +0200 +++ linux-5.18/drivers/watchdog/sp5100_tco.c 2022-06-21 15:07:31.868814828 +0200 @@ -402,6 +402,7 @@ static int sp5100_tco_setupdevice_mmio(s iounmap(addr); release_resource(res); + kfree(res); return ret; }
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. Signed-off-by: Jean Delvare <jdelvare@suse.de> Fixes: 0578fff4aae5 ("Watchdog: sp5100_tco: Add initialization using EFCH MMIO") Cc: Terry Bowman <terry.bowman@amd.com> Cc: Wim Van Sebroeck <wim@linux-watchdog.org> Cc: Guenter Roeck <linux@roeck-us.net> --- drivers/watchdog/sp5100_tco.c | 1 + 1 file changed, 1 insertion(+)