mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
binfmt/libnxflat/libnxflat_init.c: File descriptor leaks when nxflat loading fails
This commit is contained in:
committed by
Gregory Nutt
parent
683cd4c045
commit
956175d9b1
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* binfmt/libnxflat/libnxflat_init.c
|
* binfmt/libnxflat/libnxflat_init.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2018 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2018-2019 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -113,7 +113,7 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
|||||||
if (loadinfo->filfd < 0)
|
if (loadinfo->filfd < 0)
|
||||||
{
|
{
|
||||||
ret = loadinfo->filfd;
|
ret = loadinfo->filfd;
|
||||||
berr("Failed to open NXFLAT binary %s: %d\n", filename, ret);
|
berr("ERROR: Failed to open NXFLAT binary %s: %d\n", filename, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,8 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
|||||||
sizeof(struct nxflat_hdr_s), 0);
|
sizeof(struct nxflat_hdr_s), 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
berr("Failed to read NXFLAT header: %d\n", ret);
|
berr("ERROR: Failed to read NXFLAT header: %d\n", ret);
|
||||||
|
close(loadinfo->filfd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +142,8 @@ int nxflat_init(const char *filename, struct nxflat_loadinfo_s *loadinfo)
|
|||||||
* done so.
|
* done so.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
berr("Bad NXFLAT header\n");
|
berr("ERROR: Bad NXFLAT header\n");
|
||||||
|
close(loadinfo->filfd);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user