From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753340AbbFUIjt (ORCPT ); Sun, 21 Jun 2015 04:39:49 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:34981 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752302AbbFUIjj (ORCPT ); Sun, 21 Jun 2015 04:39:39 -0400 Message-ID: <1434875973.4987.1.camel@ingics.com> Subject: [PATCH] block: blk-flush: Check return value of bio_alloc() From: Axel Lin To: Jens Axboe Cc: Ming Lei , Christoph Hellwig , "linux-kernel@vger.kernel.org" Date: Sun, 21 Jun 2015 16:39:33 +0800 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bio_alloc() can return NULL, so add NULL test to prevent NULL pointer dereference. Signed-off-by: Axel Lin --- 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/