aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hostfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hostfs')
-rw-r--r--fs/hostfs/hostfs_kern.c25
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