From patchwork Tue Feb 19 14:30:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 10819969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62D8514E1 for ; Tue, 19 Feb 2019 14:30:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F3E42C505 for ; Tue, 19 Feb 2019 14:30:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C3FF2C504; Tue, 19 Feb 2019 14:30:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCF642C431 for ; Tue, 19 Feb 2019 14:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726146AbfBSOa5 (ORCPT ); Tue, 19 Feb 2019 09:30:57 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:55387 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbfBSOa5 (ORCPT ); Tue, 19 Feb 2019 09:30:57 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gw6QB-0005ZK-Db; Tue, 19 Feb 2019 14:30:55 +0000 From: Colin King To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] block: don't dereference a potential null bio pointer until is has been null checked Date: Tue, 19 Feb 2019 14:30:55 +0000 Message-Id: <20190219143055.11633-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King The bio pointer is being null checked hence it can be potentially null, however earlier it is being derefefenced on the assignment of front_seg_size. Avoid the dereference issue by only assigning front_seg_size after bios has been null sanity checked. Fixes: dcebd755926b ("block: use bio_for_each_bvec() to compute multi-page bvec count") Signed-off-by: Colin Ian King --- block/blk-merge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/blk-merge.c b/block/blk-merge.c index bed065904677..1bec20fbe465 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -379,6 +379,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, return 1; } + front_seg_size = bio->bi_seg_front_size; fbio = bio; seg_size = 0; nr_phys_segs = 0;