Skip to content

Commit

Permalink
f2fs: Fix a system panic caused by f2fs_follow_link
Browse files Browse the repository at this point in the history
In linux 3.10, we can not make sure the return value of nd_get_link function
is valid. So this patch add a check before use it.

Signed-off-by: Yunlei He <[email protected]>
Signed-off-by: Shuoran Liu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
  • Loading branch information
Yunlei He authored and kerneltoast committed Apr 2, 2016
1 parent e3f2622 commit b5a54be
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/f2fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,18 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
static void *f2fs_follow_link(struct dentry *dentry, struct nameidata *nd)
{
struct page *page;
char *link;

page = page_follow_link_light(dentry, nd);
if (IS_ERR(page))
return page;

link = nd_get_link(nd);
if (IS_ERR(link))
return link;

/* this is broken symlink case */
if (*nd_get_link(nd) == 0) {
if (*link == 0) {
kunmap(page);
page_cache_release(page);
return ERR_PTR(-ENOENT);
Expand Down

0 comments on commit b5a54be

Please sign in to comment.