Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1957272AbdDZKAw (ORCPT ); Wed, 26 Apr 2017 06:00:52 -0400 Received: from m12-18.163.com ([220.181.12.18]:43746 "EHLO m12-18.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1956476AbdDZKAn (ORCPT ); Wed, 26 Apr 2017 06:00:43 -0400 From: Heloise To: philipp.reisner@linbit.com, lars.ellenberg@linbit.com Cc: drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, Heloise Subject: [PATCH] drbd:fix null pointer deref in _drbd_md_sync_page_io Date: Wed, 26 Apr 2017 02:49:37 -0700 Message-Id: <1493200177-10699-1-git-send-email-os@iscas.ac.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: EsCowAC3g72qbwBZJtXRAg--.37502S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrKryfKw45Cw45AF47Gr1xZrb_yoW3XrgEkF 4xXrnrXr1kKr1Skr1j9345Zr9Yka18XFyxZr43tFn3Ca47XF42qrnrurn8Aws8W348Ga1v k3ZIqr1Igrn2gjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnGsjUUUUUU== X-Originating-IP: [124.16.139.198] X-CM-SenderInfo: xnhu0vxosd3uhkbx1vxdwhqiywtou0bp/xtbBSQrFglaDtqfZ9gAAsv Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 725 Lines: 26 The return value of bio_alloc_drbd can be NULL and is used without validation, which may cause null-pointer dereference, fix it. Signed-off-by: Heloise --- drivers/block/drbd/drbd_actlog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c index 8d7bcfa..d6bb30e 100644 --- a/drivers/block/drbd/drbd_actlog.c +++ b/drivers/block/drbd/drbd_actlog.c @@ -151,6 +151,10 @@ static int _drbd_md_sync_page_io(struct drbd_device *device, op_flags |= REQ_SYNC; bio = bio_alloc_drbd(GFP_NOIO); + if (!bio) { + err = -ENOMEM; + return err; + } bio->bi_bdev = bdev->md_bdev; bio->bi_iter.bi_sector = sector; err = -EIO; -- 2.1.0