All of lore.kernel.org
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] ext4: add check to io_submit_init_bio
Date: Thu, 6 Jun 2013 10:19:41 -0400	[thread overview]
Message-ID: <20130606141941.GA5382@thunk.org> (raw)
In-Reply-To: <20130606115653.a21b0c6a7bdbbbac23164b85@canb.auug.org.au>

On Thu, Jun 06, 2013 at 11:56:53AM +1000, Stephen Rothwell wrote:
> 
> In tracking this down, I followed the call chains and discovered that
> io_submit_init_bio() only ever returned 0.  Switching that to return
> void and following back up the chain lead to the following patch.

Actually, that's a bug.  We're missing an check in that function.
Thanks for looking at this code.  (I'll fix the uninitialized err
warning another way.)

						- Ted

commit 7745883f99c0e81e6bc71527d23ca363eb125a3f
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Thu Jun 6 10:18:22 2013 -0400

    ext4: add check to io_submit_init_bio
    
    The bio_alloc() function can return NULL if the memory allocation
    fails.  So we need to check for this.
    
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index ce8c15a..48786cd 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -372,6 +372,8 @@ static int io_submit_init_bio(struct ext4_io_submit *io,
 	struct bio *bio;
 
 	bio = bio_alloc(GFP_NOIO, min(nvecs, BIO_MAX_PAGES));
+	if (!bio)
+		return -ENOMEM;
 	bio->bi_sector = bh->b_blocknr * (bh->b_size >> 9);
 	bio->bi_bdev = bh->b_bdev;
 	bio->bi_end_io = ext4_end_bio;

  reply	other threads:[~2013-06-06 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06  1:56 [RFC] ext4: simplify the code a bit Stephen Rothwell
2013-06-06 14:19 ` Theodore Ts'o [this message]
2013-06-06 23:49   ` [PATCH] ext4: add check to io_submit_init_bio Stephen Rothwell

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=20130606141941.GA5382@thunk.org \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.