linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH] ndctl/namespace: Fix a resource leak in file_write_infoblock
@ 2020-03-23 18:33 Vishal Verma
  2020-03-23 18:40 ` Dan Williams
  0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2020-03-23 18:33 UTC (permalink / raw)
  To: linux-nvdimm; +Cc: Dan Williams, 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 <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/namespace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ndctl/namespace.c b/ndctl/namespace.c
index 21252b6..0550580 100644
--- a/ndctl/namespace.c
+++ b/ndctl/namespace.c
@@ -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:
-- 
2.21.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [ndctl PATCH] ndctl/namespace: Fix a resource leak in file_write_infoblock
  2020-03-23 18:33 [ndctl PATCH] ndctl/namespace: Fix a resource leak in file_write_infoblock Vishal Verma
@ 2020-03-23 18:40 ` Dan Williams
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2020-03-23 18:40 UTC (permalink / raw)
  To: Vishal Verma; +Cc: linux-nvdimm

On Mon, Mar 23, 2020 at 11:33 AM Vishal Verma <vishal.l.verma@intel.com> wrote:
>
> 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 <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  ndctl/namespace.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index 21252b6..0550580 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -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 <dan.j.williams@intel.com>
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-23 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 18:33 [ndctl PATCH] ndctl/namespace: Fix a resource leak in file_write_infoblock Vishal Verma
2020-03-23 18:40 ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).