public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@ingics.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <ming.lei@canonical.com>, Christoph Hellwig <hch@lst.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] block: blk-flush: Check return value of bio_alloc()
Date: Sun, 21 Jun 2015 16:39:33 +0800	[thread overview]
Message-ID: <1434875973.4987.1.camel@ingics.com> (raw)

bio_alloc() can return NULL, so add NULL test to prevent NULL pointer
dereference.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 block/blk-flush.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 20badd7..4706641 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -470,6 +470,9 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
 		return -ENXIO;
 
 	bio = bio_alloc(gfp_mask, 0);
+	if (!bio)
+		return -ENOMEM;
+
 	bio->bi_bdev = bdev;
 
 	ret = submit_bio_wait(WRITE_FLUSH, bio);
-- 
2.1.0



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

                 reply	other threads:[~2015-06-21  8:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1434875973.4987.1.camel@ingics.com \
    --to=axel.lin@ingics.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@canonical.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