linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Chao Yu <chao2.yu@samsung.com>
Cc: 'Jaegeuk Kim' <jaegeuk@kernel.org>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: f2fs: avoid abnormal behavior on broken symlink
Date: Wed, 22 Apr 2015 13:27:22 +0300	[thread overview]
Message-ID: <20150422102722.GK16501@mwanda> (raw)
In-Reply-To: <051e01d07cc5$9fb78370$df268a50$@samsung.com>

On Wed, Apr 22, 2015 at 02:28:22PM +0800, Chao Yu wrote:
> > > fs/f2fs/namei.c
> > >    299  static void *f2fs_follow_link(struct dentry *dentry, struct nameidata *nd)
> > >    300  {
> > >    301          struct page *page;
> > >    302
> > >    303          page = page_follow_link_light(dentry, nd);
> > >    304          if (IS_ERR(page))
> > >                            ^^^^
> > > The code in page_follow_link_light() is a bit hard to follow but it
> > > returns NULL on error.
> 
> I try to find out the other callers' error handling method for
> page_follow_link_light, and it shows all of them use the "IS_ERR" one.
> 
> In page_follow_link_light I also can't find a path which will return a NULL value.
> 
> So, Dan, is that report from smatch not true? or I made a mistake? If so, please
> correct me.

Smatch is correct, it returns NULL on error.  However, I agree that it
looks like it is supposed to return an ERR_PTR.  Every caller seems to
expect that.

I suspect the right fix is to change page_follow_link_light().  But I
don't know this code very well so I just sent the bug report instead of
fixing it myself.  :)

regards,
dan carpenter

diff --git a/fs/namei.c b/fs/namei.c
index ffab2e0..5ca251e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4473,7 +4473,12 @@ EXPORT_SYMBOL(page_readlink);
 void *page_follow_link_light(struct dentry *dentry, struct nameidata *nd)
 {
 	struct page *page = NULL;
-	nd_set_link(nd, page_getlink(dentry, &page));
+	char *link;
+
+	link = page_getlink(dentry, &page);
+	if (IS_ERR(link))
+		return link;
+	nd_set_link(nd, link);
 	return page;
 }
 EXPORT_SYMBOL(page_follow_link_light);

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF

  parent reply	other threads:[~2015-04-22 10:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-20 14:49 f2fs: avoid abnormal behavior on broken symlink Dan Carpenter
2015-04-21 18:20 ` Jaegeuk Kim
2015-04-22  6:28   ` Chao Yu
2015-04-22  7:48     ` Jaegeuk Kim
2015-04-22  9:31       ` Chao Yu
2015-04-22 16:52         ` Jaegeuk Kim
2015-04-22 10:27     ` Dan Carpenter [this message]
2015-04-22 18:13       ` Jaegeuk Kim
2015-04-22 19:19         ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150422102722.GK16501@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=chao2.yu@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).