linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext3: Check return value of sb_getblk()
@ 2010-10-19  6:34 Namhyung Kim
  2010-10-19  7:57 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2010-10-19  6:34 UTC (permalink / raw)
  To: Jan Kara, Andrew Morton, Andreas Dilger; +Cc: linux-ext4, linux-kernel

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");
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-19 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).