f2fs: Fix a system panic caused by f2fs_follow_link

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 <heyunlei@huawei.com>
Signed-off-by: Shuoran Liu <liushuoran@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Yunlei He 2015-11-28 14:38:40 +08:00 committed by Zhao Wei Liew
parent 9a7dcc468f
commit 3bdb893816

View file

@ -318,13 +318,18 @@ fail:
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);