浏览代码

devtmpfs: unlock mutex in case of string allocation error

Reported-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Kay Sievers 15 年之前
父节点
当前提交
8042273801
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      drivers/base/devtmpfs.c

+ 5 - 2
drivers/base/devtmpfs.c

@@ -101,8 +101,10 @@ static int create_path(const char *nodepath)
 
 
 		/* parent directories do not exist, create them */
 		/* parent directories do not exist, create them */
 		path = kstrdup(nodepath, GFP_KERNEL);
 		path = kstrdup(nodepath, GFP_KERNEL);
-		if (!path)
-			return -ENOMEM;
+		if (!path) {
+			err = -ENOMEM;
+			goto out;
+		}
 		s = path;
 		s = path;
 		for (;;) {
 		for (;;) {
 			s = strchr(s, '/');
 			s = strchr(s, '/');
@@ -117,6 +119,7 @@ static int create_path(const char *nodepath)
 		}
 		}
 		kfree(path);
 		kfree(path);
 	}
 	}
+out:
 	mutex_unlock(&dirlock);
 	mutex_unlock(&dirlock);
 	return err;
 	return err;
 }
 }