Skip to content

Commit

Permalink
hostfs: Use __getname() in follow_link
Browse files Browse the repository at this point in the history
Be consistent with all other functions in hostfs and just
use __getname().

Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Richard Weinberger committed Mar 26, 2015
1 parent c278e81 commit 7c95099
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,19 @@ static char *follow_link(char *link)
int len, n;
char *name, *resolved, *end;

len = 64;
while (1) {
name = __getname();
if (!name) {
n = -ENOMEM;
name = kmalloc(len, GFP_KERNEL);
if (name == NULL)
goto out;

n = hostfs_do_readlink(link, name, len);
if (n < len)
break;
len *= 2;
kfree(name);
goto out_free;
}

n = hostfs_do_readlink(link, name, PATH_MAX);
if (n < 0)
goto out_free;
else if (n == PATH_MAX) {
n = -E2BIG;
goto out_free;
}

if (*name == '/')
return name;
Expand All @@ -175,13 +173,12 @@ static char *follow_link(char *link)
}

sprintf(resolved, "%s%s", link, name);
kfree(name);
__putname(name);
kfree(link);
return resolved;

out_free:
kfree(name);
out:
__putname(name);
return ERR_PTR(n);
}

Expand Down

0 comments on commit 7c95099

Please sign in to comment.