[Skiboot] [PATCH 11/13] libflash: fix memory leak on flash_exit()
Stewart Smith
stewart at linux.vnet.ibm.com
Wed Aug 23 17:21:21 AEST 2017
LeakSanitizer caught this with libflash/test/test-flash.c:
Direct leak of 4096 byte(s) in 1 object(s) allocated from:
#0 0x7f72546ee850 in malloc (/lib64/libasan.so.4+0xde850)
#1 0x405ff0 in flash_init libflash/test/../libflash.c:830
#2 0x408632 in main libflash/test/test-flash.c:382
#3 0x7f7253540509 in __libc_start_main (/lib64/libc.so.6+0x20509)
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
libflash/libflash.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libflash/libflash.c b/libflash/libflash.c
index 38f87b86eb24..bf2e58e3465f 100644
--- a/libflash/libflash.c
+++ b/libflash/libflash.c
@@ -863,8 +863,11 @@ bail:
void flash_exit(struct blocklevel_device *bl)
{
/* XXX Make sure we are idle etc... */
- if (bl)
- free(container_of(bl, struct flash_chip, bl));
+ if (bl) {
+ struct flash_chip *c = container_of(bl, struct flash_chip, bl);
+ free(c->smart_buf);
+ free(c);
+ }
}
void flash_exit_close(struct blocklevel_device *bl, void (*close)(struct spi_flash_ctrl *ctrl))
--
2.13.5
More information about the Skiboot
mailing list