* [PATCH] xfs_spaceman: close open file for error case in openfile()
@ 2017-06-29 16:25 Bill O'Donnell
2017-06-29 16:27 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Bill O'Donnell @ 2017-06-29 16:25 UTC (permalink / raw)
To: linux-xfs; +Cc: sandeen
openfile() fails to close the open file in one error case.
Add close(fd) to correct the condition.
Detected by CoverityScan, CID#1413770 (RESOURCE_LEAK)
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
spaceman/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/spaceman/file.c b/spaceman/file.c
index 4ab30900..4c13b4a8 100644
--- a/spaceman/file.c
+++ b/spaceman/file.c
@@ -79,6 +79,7 @@ openfile(
if (!fsp) {
fprintf(stderr, _("%s: cannot find mount point."),
path);
+ close(fd);
return -1;
}
memcpy(fs_path, fsp, sizeof(struct fs_path));
--
2.13.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfs_spaceman: close open file for error case in openfile()
2017-06-29 16:25 [PATCH] xfs_spaceman: close open file for error case in openfile() Bill O'Donnell
@ 2017-06-29 16:27 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2017-06-29 16:27 UTC (permalink / raw)
To: Bill O'Donnell; +Cc: linux-xfs, sandeen
On Thu, Jun 29, 2017 at 11:25:30AM -0500, Bill O'Donnell wrote:
> openfile() fails to close the open file in one error case.
> Add close(fd) to correct the condition.
>
> Detected by CoverityScan, CID#1413770 (RESOURCE_LEAK)
>
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> spaceman/file.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/spaceman/file.c b/spaceman/file.c
> index 4ab30900..4c13b4a8 100644
> --- a/spaceman/file.c
> +++ b/spaceman/file.c
> @@ -79,6 +79,7 @@ openfile(
> if (!fsp) {
> fprintf(stderr, _("%s: cannot find mount point."),
> path);
> + close(fd);
> return -1;
> }
> memcpy(fs_path, fsp, sizeof(struct fs_path));
> --
> 2.13.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-29 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 16:25 [PATCH] xfs_spaceman: close open file for error case in openfile() Bill O'Donnell
2017-06-29 16:27 ` Darrick J. Wong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.