From: Jan Kara <jack@suse.cz>
To: Namhyung Kim <namhyung@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext3: Check return value of sb_getblk()
Date: Tue, 19 Oct 2010 22:41:28 +0200 [thread overview]
Message-ID: <20101019204127.GB3487@quack.suse.cz> (raw)
In-Reply-To: <1287475049.1705.2.camel@leonhard>
On Tue 19-10-10 16:57:29, Namhyung Kim wrote:
> 2010-10-19 (화), 15:34 +0900, Namhyung Kim:
> > Check return value of sb_getblk() is NULL. unlikely is addded here
> > since it is called from a loop and we've been OK without the check
> > until now.
> >
> > Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> > ---
> > fs/ext3/inode.c | 6 ++++++
> > 1 files changed, 6 insertions(+), 0 deletions(-)
> >
> > diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
> > index ef1c23a..a7ac778 100644
> > --- a/fs/ext3/inode.c
> > +++ b/fs/ext3/inode.c
> > @@ -655,6 +655,12 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
> > * parent to disk.
> > */
> > bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
> > + if (unlikely(!bh)) {
> > + n--;
> > + err = -ENOMEM;
> > + goto failed;
> > + }
> > +
> > branch[n].bh = bh;
> > lock_buffer(bh);
> > BUFFER_TRACE(bh, "call get_create_access");
>
> Maybe EIO would be more proper error code, I guess.
Hmm, for ext3, sb_getblk() cannot really realistically fail. Block
numbers are 32-bit so they can never be big enough to overflow pagecache
index and grow_buffers() loops indefinitely if it cannot allocate buffers.
But OK, EIO might be a reasonable return value and we can have the check
there just in case sb_getblk() grows some other possiblility to fail.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2010-10-19 20:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-19 6:34 [PATCH] ext3: Check return value of sb_getblk() Namhyung Kim
2010-10-19 7:57 ` Namhyung Kim
2010-10-19 20:41 ` Jan Kara [this message]
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=20101019204127.GB3487@quack.suse.cz \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
/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).