ndctl/namespace: Fix a resource leak in file_write_infoblock
Vishal Verma
maintainerPATCH 1/1 ndctl/namespace: Fix a resource leak in file_write_infoblock
Static analysis reported that we were leaking 'fd' in one case in the above function, fix the error handling to go through the 'out' label.
Cc Dan Williams <[email protected]>
Signed-off-by Vishal Verma <[email protected]>
--- ndctl/namespace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
ndctl/namespace.c +4 -2
@@ -1958,8 +1958,10 @@ static int file_write_infoblock(const char *path) } buf =calloc (INFOBLOCK_SZ ,1 ); -if (!buf) -return -ENOMEM ; +if (!buf) { + rc = -ENOMEM ; + goto out; + }switch (util_nsmode (param.mode)) {case NDCTL_NS_MODE_FSDAX :
Signature · 4 lines
2.21.1 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Quoted 15 lines · Vishal Verma
Static analysis reported that we were leaking 'fd' in one case in the above function, fix the error handling to go through the 'out' label.
Cc Dan Williams <[email protected]>Signed-off-by Vishal Verma <[email protected]>--- ndctl/namespace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)ndctl/namespace.c +0
-0
ndctl/namespace.c static int file_write_infoblock(const char *path) · line 1964
Quoted 9 lines
ndctl/namespace.c +4
-2@@ -1958,8 +1958,10 @@ static int file_write_infoblock(const char *path) } buf =calloc (INFOBLOCK_SZ ,1 ); -if (!buf) -return -ENOMEM ; +if (!buf) { + rc = -ENOMEM ; + goto out; + }
Looks good:
Reviewed-by Dan Williams <[email protected]>
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]