f2fs crypto: clean up error handling in f2fs_fname_setup_filename
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 29 May 2015 00:06:40 +0000 (17:06 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 1 Jun 2015 23:21:08 +0000 (16:21 -0700)
Sync with:
  ext4 crypto: clean up error handling in ext4_fname_setup_filename

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/crypto_fname.c

index 81852cca7bbe395eebad0a017abe91317b6f67e4..ab377d496a39ad47924a3f79b48e1aad7538f2d2 100644 (file)
@@ -392,15 +392,13 @@ int f2fs_fname_setup_filename(struct inode *dir, const struct qstr *iname,
                        return ret;
                ret = f2fs_fname_encrypt(dir, iname, &fname->crypto_buf);
                if (ret < 0)
-                       goto out;
+                       goto errout;
                fname->disk_name.name = fname->crypto_buf.name;
                fname->disk_name.len = fname->crypto_buf.len;
                return 0;
        }
-       if (!lookup) {
-               ret = -EACCES;
-               goto out;
-       }
+       if (!lookup)
+               return -EACCES;
 
        /* We don't have the key and we are doing a lookup; decode the
         * user-supplied name
@@ -408,19 +406,17 @@ int f2fs_fname_setup_filename(struct inode *dir, const struct qstr *iname,
        if (iname->name[0] == '_')
                bigname = 1;
        if ((bigname && (iname->len != 33)) ||
-           (!bigname && (iname->len > 43))) {
-               ret = -ENOENT;
-       }
+           (!bigname && (iname->len > 43)))
+               return -ENOENT;
+
        fname->crypto_buf.name = kmalloc(32, GFP_KERNEL);
-       if (fname->crypto_buf.name == NULL) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (fname->crypto_buf.name == NULL)
+               return -ENOMEM;
        ret = digest_decode(iname->name + bigname, iname->len - bigname,
                                fname->crypto_buf.name);
        if (ret < 0) {
                ret = -ENOENT;
-               goto out;
+               goto errout;
        }
        fname->crypto_buf.len = ret;
        if (bigname) {
@@ -430,7 +426,7 @@ int f2fs_fname_setup_filename(struct inode *dir, const struct qstr *iname,
                fname->disk_name.len = fname->crypto_buf.len;
        }
        return 0;
-out:
+errout:
        f2fs_fname_crypto_free_buffer(&fname->crypto_buf);
        return ret;
 }