diff options
author | Richard Weinberger <richard@nod.at> | 2015-03-03 17:55:49 -0500 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2015-03-26 18:27:50 -0400 |
commit | 7c9509924c711d45d7932548d2c632f44f64e7e3 (patch) | |
tree | 9c2f6be2f0622025cd308e990716224e0e7ca5f4 /fs/hostfs | |
parent | c278e81b8a0291f5adce43c4613ad569d76dc384 (diff) |
hostfs: Use __getname() in follow_link
Be consistent with all other functions in hostfs and just
use __getname().
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/hostfs')
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 7260f162db41..c60d886230ef 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -142,21 +142,19 @@ static char *follow_link(char *link) | |||
142 | int len, n; | 142 | int len, n; |
143 | char *name, *resolved, *end; | 143 | char *name, *resolved, *end; |
144 | 144 | ||
145 | len = 64; | 145 | name = __getname(); |
146 | while (1) { | 146 | if (!name) { |
147 | n = -ENOMEM; | 147 | n = -ENOMEM; |
148 | name = kmalloc(len, GFP_KERNEL); | 148 | goto out_free; |
149 | if (name == NULL) | ||
150 | goto out; | ||
151 | |||
152 | n = hostfs_do_readlink(link, name, len); | ||
153 | if (n < len) | ||
154 | break; | ||
155 | len *= 2; | ||
156 | kfree(name); | ||
157 | } | 149 | } |
150 | |||
151 | n = hostfs_do_readlink(link, name, PATH_MAX); | ||
158 | if (n < 0) | 152 | if (n < 0) |
159 | goto out_free; | 153 | goto out_free; |
154 | else if (n == PATH_MAX) { | ||
155 | n = -E2BIG; | ||
156 | goto out_free; | ||
157 | } | ||
160 | 158 | ||
161 | if (*name == '/') | 159 | if (*name == '/') |
162 | return name; | 160 | return name; |
@@ -175,13 +173,12 @@ static char *follow_link(char *link) | |||
175 | } | 173 | } |
176 | 174 | ||
177 | sprintf(resolved, "%s%s", link, name); | 175 | sprintf(resolved, "%s%s", link, name); |
178 | kfree(name); | 176 | __putname(name); |
179 | kfree(link); | 177 | kfree(link); |
180 | return resolved; | 178 | return resolved; |
181 | 179 | ||
182 | out_free: | 180 | out_free: |
183 | kfree(name); | 181 | __putname(name); |
184 | out: | ||
185 | return ERR_PTR(n); | 182 | return ERR_PTR(n); |
186 | } | 183 | } |
187 | 184 | ||