Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp390599rwr; Thu, 20 Apr 2023 00:27:38 -0700 (PDT) X-Google-Smtp-Source: AKy350ZJY5v8NDvgpf5na6hR3+W3VbHU6zt82BTEPCZKddeCB4VFBO5o+pxrrt84BDJu/HuQ+RN4 X-Received: by 2002:a05:6a00:24c9:b0:624:2e60:f21e with SMTP id d9-20020a056a0024c900b006242e60f21emr285262pfv.29.1681975658402; Thu, 20 Apr 2023 00:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681975658; cv=none; d=google.com; s=arc-20160816; b=q0h6EwP5auK5PzaoxcWIFG5+Ovo5iME3+64ogGvDPN+Vk1+/Z6WE9HFplXRXlXK4Np 15wBSE2LAV82Q86NVI0ECmjwJMyRMlrCa6G4oYRnKYDWjgKvL8eNKzQwQQ2jMRV8ao2l 3bOduO8nopqziztkPmWq1+LfIoCc42tRJxUwTxA4xeujkfVeZhCI7Gx4Pz8Kkz3vIM6U rTY6KF54GzxxENZYJtVgdZ675NBygdYUiWU8CUHgq2zaMBDPcWl8iRmvTW0Ofd+4JFIB tkNGTOcnBAjB5LlgJrJt3hPyHoUR9pDj8BYXx8859/Z+sIPdU7mGuteeMXY8dL/bOueJ 6lhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BinArMeIu3kbYSgmasOaJJzxzXIJu8lCXv0hNRpOuZc=; b=eMo+V8EPDcdJSV4P3XI2bSsaO8ciY6Wb4ZGt2kmm51Z+kFZNS9S+2Q/DkodWvaZY0m JpsL/rQlufdEFXGwuhWXuh1O+jY8hxEX96dJlzU+CvZQMH0k+Wk+GruZPTfncbHnB8Hw y0r47o9NU3GL15aCq7wj8YIB+QNDBfspaNRK2mZ4aiPbac6ijn4GarsGJgxaM40fjFXS KWuYRckgEJwSVveHA0uJ2mamWn3fQJYbfXNaStai05gESyhOLmTlpTQsXqEKHUVe43mV AGI2x507cqF1ypEK4iFzvHsCk6OkdKHcyjcscWVXZRZusIeyrzX46t6T8oGJ0+fgFKTg 7NFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=fcf275M+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a634b55000000b0051f92bf001bsi843529pgl.662.2023.04.20.00.27.24; Thu, 20 Apr 2023 00:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=fcf275M+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234013AbjDTHVG (ORCPT + 99 others); Thu, 20 Apr 2023 03:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbjDTHVF (ORCPT ); Thu, 20 Apr 2023 03:21:05 -0400 X-Greylist: delayed 120 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Apr 2023 00:21:01 PDT Received: from forwardcorp1c.mail.yandex.net (forwardcorp1c.mail.yandex.net [178.154.239.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B93B51713; Thu, 20 Apr 2023 00:21:01 -0700 (PDT) Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c00:2582:0:640:9a17:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 0DD515FCA9; Thu, 20 Apr 2023 10:18:57 +0300 (MSK) Received: from d-tatianin-nix.yandex-team.ru (unknown [2a02:6b8:b081:b409::1:14]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id qIYucs0OrW20-wj8KMKWB; Thu, 20 Apr 2023 10:18:56 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1681975136; bh=BinArMeIu3kbYSgmasOaJJzxzXIJu8lCXv0hNRpOuZc=; h=Message-Id:Date:Cc:Subject:To:From; b=fcf275M+qVSkY2y//2FVVk8kqqNNjQ2q56qyuWLI8+Yz6wZZB3p77kiwAUBESsWjc p/rB38rQVlhRaTTD/FtJdd8uFRAgr+BEu0cWG64dqTSt5Zkl5d0pl2SOdm8JV5wnaE plPQkVf7JEQsGIG87KvmDx2UHBsD4wI/RbuGLveQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Daniil Tatianin To: Song Liu Cc: Daniil Tatianin , linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] md/md-multipath: guard against a possible NULL dereference Date: Thu, 20 Apr 2023 10:18:51 +0300 Message-Id: <20230420071851.326726-1-d-tatianin@yandex-team.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mempool_alloc might fail to allocate a slot, in which case we will end up dereferencing a NULL mp_bh pointer. Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Daniil Tatianin --- drivers/md/md-multipath.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c index 66edf5e72bd6..861c70e49bcc 100644 --- a/drivers/md/md-multipath.c +++ b/drivers/md/md-multipath.c @@ -108,6 +108,8 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio) return true; mp_bh = mempool_alloc(&conf->pool, GFP_NOIO); + if (!map_bh) + return false; mp_bh->master_bio = bio; mp_bh->mddev = mddev; -- 2.25.1