Skip to content

Commit

Permalink
ndctl/namespace: Fix a resource leak in file_write_infoblock
Browse files Browse the repository at this point in the history
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]>
Reviewed-by: Dan Williams <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vishal Verma <[email protected]>
  • Loading branch information
stellarhopper committed Mar 23, 2020
1 parent 24baeb0 commit 1f8e0d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ndctl/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1f8e0d1

Please sign in to comment.