Stefan Reinauer has submitted this change. ( https://review.coreboot.org/c/em100/+/37480 )
Change subject: Run closedir() only if opendir() succeeded ......................................................................
Run closedir() only if opendir() succeeded
Otherwise we operate on a non-existing DIR * handle.
Change-Id: Ib977b50cb61b5b396ecbc2d911a0876518115a81 Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Reviewed-on: https://review.coreboot.org/c/em100/+/37480 Reviewed-by: Patrick Georgi pgeorgi@google.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M em100.c 1 file changed, 2 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved
diff --git a/em100.c b/em100.c index 7b1e068..1f9f4b6 100644 --- a/em100.c +++ b/em100.c @@ -720,7 +720,8 @@
DIR *dir = opendir(directory); if (dir) { - // success + /* success */ + closedir(dir); } else if (errno == ENOENT) { if (mkdir(directory, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) { perror(directory); @@ -733,7 +734,6 @@ return NULL; }
- closedir(dir); return directory; }