aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2021-06-18 10:29:56 +0900
committerNamjae Jeon <namjae.jeon@samsung.com>2021-06-22 16:11:34 +0900
commit1dfb8242e8d982d036399766c4af62ddc221e38d (patch)
treea788e34adedaab98a2a485986ffa9c667ad35aaf
parentksmbd: use list_for_each_entry instead of list_for_each (diff)
downloadwireguard-linux-1dfb8242e8d982d036399766c4af62ddc221e38d.tar.xz
wireguard-linux-1dfb8242e8d982d036399766c4af62ddc221e38d.zip
ksmbd: use goto instead of duplicating the resoure cleanup in ksmbd_open_fd
Use goto instead of duplicating the resoure cleanup in ksmbd_open_fd. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/cifsd/vfs_cache.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/fs/cifsd/vfs_cache.c b/fs/cifsd/vfs_cache.c
index 3f18018668b6..71a11128d908 100644
--- a/fs/cifsd/vfs_cache.c
+++ b/fs/cifsd/vfs_cache.c
@@ -559,19 +559,22 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp)
fp->f_ci = ksmbd_inode_get(fp);
if (!fp->f_ci) {
- kmem_cache_free(filp_cache, fp);
- return ERR_PTR(-ENOMEM);
+ ret = -ENOMEM;
+ goto err_out;
}
ret = __open_id(&work->sess->file_table, fp, OPEN_ID_TYPE_VOLATILE_ID);
if (ret) {
ksmbd_inode_put(fp->f_ci);
- kmem_cache_free(filp_cache, fp);
- return ERR_PTR(ret);
+ goto err_out;
}
atomic_inc(&work->conn->stats.open_files_count);
return fp;
+
+err_out:
+ kmem_cache_free(filp_cache, fp);
+ return ERR_PTR(ret);
}
static int