From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH 2/2] Ext3: add necessary check in case IO error happens Date: Fri, 11 Jan 2013 17:26:33 +0100 Message-ID: <20130111162633.GD16923@quack.suse.cz> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org To: shilong wang Return-path: Received: from cantor2.suse.de ([195.135.220.15]:41090 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753938Ab3AKQ0e (ORCPT ); Fri, 11 Jan 2013 11:26:34 -0500 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri 11-01-13 03:58:28, shilong wang wrote: > From: Wang Shilong > > As we know IO ERROR may happen when the function 'sb_getblk' is > called. Add necessary check for it. > > The patch also fix a coding style problem. Thanks for the patch. I think returning ENOMEM instead of EIO would be better. Otherwise the patch looks OK. Honza > > Signed-off-by: Wang Shilong > --- > fs/ext3/inode.c | 6 +++++- > 1 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c > index ff574b4..59b6178 100644 > --- a/fs/ext3/inode.c > +++ b/fs/ext3/inode.c > @@ -676,6 +676,10 @@ 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 (!bh) { > + err = -EIO; > + goto failed; > + } > branch[n].bh = bh; > lock_buffer(bh); > BUFFER_TRACE(bh, "call get_create_access"); > @@ -717,7 +721,7 @@ failed: > BUFFER_TRACE(branch[i].bh, "call journal_forget"); > ext3_journal_forget(handle, branch[i].bh); > } > - for (i = 0; i + for (i = 0; i < indirect_blks; i++) > ext3_free_blocks(handle, inode, new_blocks[i], 1); > > ext3_free_blocks(handle, inode, new_blocks[i], num); > -- > 1.7.7.6 > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Jan Kara SUSE Labs, CR