Skip to content

Commit

Permalink
plugins/micron: Fix code scanning alert
Browse files Browse the repository at this point in the history
Fix the time-of-check time-of-use filesystem race condition.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
  • Loading branch information
ikegami-t committed Feb 11, 2024
1 parent 83aad43 commit d9529f2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/micron/micron-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ static int SetupDebugDataDirectories(char *strSN, char *strFilePath,
if (strOSDirName) {
sprintf(strOSDirName, "%s/%s", strMainDirName, "OS");
if (mkdir(strOSDirName, 0777) < 0) {
rmdir(strMainDirName);
if (strMainDirName)
rmdir(strMainDirName);
err = -1;
goto exit_status;
}
Expand All @@ -329,9 +330,10 @@ static int SetupDebugDataDirectories(char *strSN, char *strFilePath,
if (mkdir(strCtrlDirName, 0777) < 0) {
if (strOSDirName)
rmdir(strOSDirName);
rmdir(strMainDirName);
if (strMainDirName)
rmdir(strMainDirName);
err = -1;
}
}
}

exit_status:
Expand Down

0 comments on commit d9529f2

Please sign in to comment.