Skip to contentSkip to conversation

proc01: Close the opened file

PATCH New zhanglianjie 2 participants 2 messages Apr 29, 2021 – Apr 30, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc01: Close the opened file

---
 testcases/kernel/fs/proc/proc01.c | 2 ++
 1 file changed, 2 insertions(+)
testcases/kernel/fs/proc/proc01.c +2 -0
index 96441d153..0fae6754f 100644
@@ -368,6 +368,7 @@ static long readproc(const char *obj)
 		if ((statbuf.st_mode & S_IRUSR) == 0 &&
 		    (statbuf.st_mode & S_IWUSR) != 0) {
 			tst_resm(TINFO, "%s: is write-only.", obj);
+			(void)close(fd);
 			return 0;
 		}
 
@@ -376,6 +377,7 @@ static long readproc(const char *obj)
 			if (!strcmp(obj, error_nonblock[i])) {
 				tst_resm(TINFO, "%s: does not honor "
 					 "O_NONBLOCK", obj);
+				(void)close(fd);
 				return 0;
 			}
 		}

--
2.20.1