瀏覽代碼

hostfs: hostfs_file_open: Fix a fd leak in hostfs_file_open

In case of a race between to callers of hostfs_file_open()
it can happen that a file describtor is leaked.

Signed-off-by: Richard Weinberger <richard@nod.at>
Richard Weinberger 10 年之前
父節點
當前提交
af9556586a
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      fs/hostfs/hostfs_kern.c

+ 1 - 0
fs/hostfs/hostfs_kern.c

@@ -329,6 +329,7 @@ retry:
 	/* somebody else had handled it first? */
 	/* somebody else had handled it first? */
 	if ((mode & HOSTFS_I(ino)->mode) == mode) {
 	if ((mode & HOSTFS_I(ino)->mode) == mode) {
 		mutex_unlock(&HOSTFS_I(ino)->open_mutex);
 		mutex_unlock(&HOSTFS_I(ino)->open_mutex);
+		close_file(&fd);
 		return 0;
 		return 0;
 	}
 	}
 	if ((mode | HOSTFS_I(ino)->mode) != mode) {
 	if ((mode | HOSTFS_I(ino)->mode) != mode) {