diff options
author | NeilBrown <neilb@suse.de> | 2015-03-22 22:37:39 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-05-10 22:18:20 -0400 |
commit | 3188b2955de3d01949ec54eb2c9ff1ecaa0a752d (patch) | |
tree | d1e1574a54ab99b47220b33bae4d1521fc7daebb /fs/overlayfs | |
parent | 90e4fc8890daecea72ef73ac8047050e3e8d32db (diff) |
ovl: rearrange ovl_follow_link to it doesn't need to call ->put_link
ovl_follow_link current calls ->put_link on an error path.
However ->put_link is about to change in a way that it will be
impossible to call it from ovl_follow_link.
So rearrange the code to avoid the need for that error path.
Specifically: move the kmalloc() call before the ->follow_link()
call to the subordinate filesystem.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/overlayfs')
-rw-r--r-- | fs/overlayfs/inode.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 04f124884687..1b4b9c5e51b7 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -145,6 +145,7 @@ static void *ovl_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
145 | void *ret; | 145 | void *ret; |
146 | struct dentry *realdentry; | 146 | struct dentry *realdentry; |
147 | struct inode *realinode; | 147 | struct inode *realinode; |
148 | struct ovl_link_data *data = NULL; | ||
148 | 149 | ||
149 | realdentry = ovl_dentry_real(dentry); | 150 | realdentry = ovl_dentry_real(dentry); |
150 | realinode = realdentry->d_inode; | 151 | realinode = realdentry->d_inode; |
@@ -152,25 +153,23 @@ static void *ovl_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
152 | if (WARN_ON(!realinode->i_op->follow_link)) | 153 | if (WARN_ON(!realinode->i_op->follow_link)) |
153 | return ERR_PTR(-EPERM); | 154 | return ERR_PTR(-EPERM); |
154 | 155 | ||
155 | ret = realinode->i_op->follow_link(realdentry, nd); | ||
156 | if (IS_ERR(ret)) | ||
157 | return ret; | ||
158 | |||
159 | if (realinode->i_op->put_link) { | 156 | if (realinode->i_op->put_link) { |
160 | struct ovl_link_data *data; | ||
161 | |||
162 | data = kmalloc(sizeof(struct ovl_link_data), GFP_KERNEL); | 157 | data = kmalloc(sizeof(struct ovl_link_data), GFP_KERNEL); |
163 | if (!data) { | 158 | if (!data) |
164 | realinode->i_op->put_link(realdentry, nd, ret); | ||
165 | return ERR_PTR(-ENOMEM); | 159 | return ERR_PTR(-ENOMEM); |
166 | } | ||
167 | data->realdentry = realdentry; | 160 | data->realdentry = realdentry; |
168 | data->cookie = ret; | 161 | } |
169 | 162 | ||
170 | return data; | 163 | ret = realinode->i_op->follow_link(realdentry, nd); |
171 | } else { | 164 | if (IS_ERR(ret)) { |
172 | return NULL; | 165 | kfree(data); |
166 | return ret; | ||
173 | } | 167 | } |
168 | |||
169 | if (data) | ||
170 | data->cookie = ret; | ||
171 | |||
172 | return data; | ||
174 | } | 173 | } |
175 | 174 | ||
176 | static void ovl_put_link(struct dentry *dentry, struct nameidata *nd, void *c) | 175 | static void ovl_put_link(struct dentry *dentry, struct nameidata *nd, void *c) |