From patchwork Wed Apr 19 14:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13216885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57E14C77B75 for ; Wed, 19 Apr 2023 14:10:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5A8590000D; Wed, 19 Apr 2023 10:10:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB911900007; Wed, 19 Apr 2023 10:10:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6FEC90000D; Wed, 19 Apr 2023 10:10:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8B5B2900007 for ; Wed, 19 Apr 2023 10:10:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 666311C60FA for ; Wed, 19 Apr 2023 14:10:56 +0000 (UTC) X-FDA: 80698326912.20.FF1107F Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf12.hostedemail.com (Postfix) with ESMTP id 827404000E for ; Wed, 19 Apr 2023 14:10:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf12.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681913454; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8TpFiJZXriCSIuX4H6qm/DmnDRMN3dAYFyNsYcZw7Y=; b=5HFrYsMKCGfLjo4wyxqcyqQeT7SgIoeNcrVwNHIkOXAuhwjnZnlW3W7O4B5XuO1RZUlTCv 6jD3Ic7O0oJsKDRt8TKU+qYeBhqcixcUSWgb1+CWXSDzhql799DBsuutyyPwzY8C4yZ8wK UlGpWRKI4DGs21BSml72UahwWTm3iI4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf12.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681913454; a=rsa-sha256; cv=none; b=KD9xNiPiCJFInYd08W7RrlhHLdstAHG7pFdf3FOkoFIX81lRHWA12lkiUqGp12WdZPIByk vJ4bYKOdS00eXtCPthd74lRSEAj9/wyKQIFJT+ZlAlNqu2BYbpIpWuBhp2IMztzIz2MyEs +Ygus3WgM7Uk5ty+OKYzXA+zyr1jrds= Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-3f0a00a5880so21531905e9.0 for ; Wed, 19 Apr 2023 07:10:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681913453; x=1684505453; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u8TpFiJZXriCSIuX4H6qm/DmnDRMN3dAYFyNsYcZw7Y=; b=IA//vZBmDzt/4gRGZ5sF7eT6nn2KkdeC96ACx0U135m7MPdLEjpjkX+jzGApIb9ksO B27ngJ7To3WazHhEF8cgNenJGAJrV94PXC0LRH88F3ZtkJbturL/bXrNOaOnbUtKqCGZ zwis8F4cA4MksoqG5ZPwaTsSjlTQQfdKoeWsw8968AAynR2YvOAum3+aauD9bdU5Q35M gaIJk9x9As4nOqAGuITKgb08lN7Rpbjg4JqSeSvSsmLAcpXrmhDh/z5UqZc3f5DByzrj v6nM/koLT9UiuCwgACyuxKgJmyZp/zvDKx8iGCoJUb6yYnI9wzHSP2v8fg7gx1dRwLxg OnKA== X-Gm-Message-State: AAQBX9dUeIZT0gS7xZVCbiE5sE5YbQcslLGhVqHZvLE2yUFYTFO2amIv WSDppYt1aXnUWp4ovm0EAMo= X-Google-Smtp-Source: AKy350YTktz+btoYf/lfmIpjxtv9Fic8XsjroznIk6ubZ5/gLPCuphxcjC60RHARQGdGgdBUYUfVfA== X-Received: by 2002:adf:e58a:0:b0:2ef:1c8c:1113 with SMTP id l10-20020adfe58a000000b002ef1c8c1113mr5538098wrm.9.1681913453067; Wed, 19 Apr 2023 07:10:53 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-204.dynamic.mnet-online.de. [62.216.205.204]) by smtp.googlemail.com with ESMTPSA id q17-20020a5d61d1000000b002faaa9a1721sm7612089wrv.58.2023.04.19.07.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 07:10:52 -0700 (PDT) From: Johannes Thumshirn To: axboe@kernel.dk Cc: johannes.thumshirn@wdc.com, agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, dsterba@suse.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-raid@vger.kernel.org, ming.lei@redhat.com, rpeterso@redhat.com, shaggy@kernel.org, snitzer@kernel.org, song@kernel.org, willy@infradead.org, Damien Le Moal Subject: [PATCH v3 15/19] md: check for failure when adding pages in alloc_behind_master_bio Date: Wed, 19 Apr 2023 16:09:25 +0200 Message-Id: <20230419140929.5924-16-jth@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230419140929.5924-1-jth@kernel.org> References: <20230419140929.5924-1-jth@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 827404000E X-Stat-Signature: kddj38c7j3px8s78xxgxetyhfa7mk6i6 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681913454-473472 X-HE-Meta: U2FsdGVkX1/hr6Ra4g+ImCiiJMUIC963CjION+SCblygugvO0lM4ljPwU7pMzaCn2RWH+yAEuQs31CJqcHLqt86PjgRig8zQaktHH4FDS5RbNJ1KeLwFLWRGlOq3b5gH+4G/sYTjy48z3/trloWvdUAXz+09Yh4PbtLzW92Uz1B3mZ9ZRgYdNv7TX0FenIpfU6SDGlZ14Yu/PqxfIME23TxSb22z0rMWYkuXkNfgjjVN/rMQRWLTBA/wrX6oSqlZwRghgDCaCAjs5EW5IcmM226LP8UCSnzBPSrF7oAvxqUjBmacEFiKDlvBTShvGkz7t2NhEZQdML/DEjEsVYv1N74FKQAQuScojZjF4JK/t8CZZ36YhZOg01w4C0PWmPVrPFEx867BeQmT3z74wa5gl8M5BMazj680DfdD8ueZz1dJ1bvCWlI2/eN6WOEx1aranCmnD2LqUgtJvQ/N0M4I0peO/ZYgFW3W/rXDSjeKfuTovqmINsTr+KYs4ME/kF/bxOPk3dp0UETqo/V/w8ny6jSKlC8YzVTCDdGAZPn0qtbPfN8YnBxRZGBG3dqHwHAG/nW6E7e3xwCm0abOXj2+/DH+UosyOGJKrvBrUA+SckSONl1TtxNqiXFhqxeEly5r4jlhb5u88C6MEsnkA6J9JR4z+VKSWOFypoDTSlEZYmN0R9WIvtT4+TsaaanVreeb8QZdsqBmExl0jtReuaL0BsG9mCeSGYB1cr8KBNP+c7q2voWVPOWKzCKQ/LKNP6yQVphu2kO0in1ZcWYiyGLfwjStxCBEIRHTugVpzdxl16xES8a2Rx9GrxjbGqxXgbVRNqiRXfPGPsGWJH6uK+17/DezVDj6eMT0S6QoSlkEY4kSsqrXqDPpAHjPK+8Cgg3RMrYWBWvKiEsUgct5XRSWTT2v4ANt8MOL4XDOR1O1IkP097fbicXJycsWJouu1CiZz49dwA8OqU1zC/REWtS 4yd3o/tj EhEJNG+F3k0KiwcM8V7rFFuTkS+dRxK9FciQLej6ArphwlEvTkI5FDf8Ug9WjYF8HD2dlrkgrcqRW27N49JBpSDh/qbOSdFSLNo/i8NoblkYOj2Ewgn4gs3MFio0OevPZq3k2Lo67SYEnY9GPmw49nARX2fyr5Yk+Syj1d00aXds+0aJ1xjU1DhhKyEKtXtPLblRPrmSweaFzPSLERJY9KLpcPDr6w6jsmQJvTYtRg/anBqAEBQTla7XUOjdq6YAFIiZh19TwYplrnbxqMcFKfJLwEA+KKrUNl9oDIvkqd1Uqgu1VLjcbXBhEIQFsX71NBIidKVessp0/Q3y36Kw2idzG7rD523K6XjS8pwosR/OqDvMt0PucxhorVlsn1CZ0+mV4SSNGjQ7Wte5GHDnZg2Ek2KsgWyk6KibautLVyWvy/xnmGClqVmwLy4GmZwezjAKXZ9TPSbA+Omf1Bf8ATjxYV7Eso6yeiarueY8YLoqvxEEAPvCFurscRckmtYXBwJMgNDOYyLOmcJ1dKZhhPN5VPf0CHidK9dflYu47ywJbhioe9i3AbHZTVKd8MNwbX06OOO4DlRz8+YnRXkgd7JbhIigna3xxQxr2d+eMUS6dxoHiUyfn8b6E2I+1kq1w4RWp X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Johannes Thumshirn alloc_behind_master_bio() can possibly add multiple pages to a bio, but it is not checking for the return value of bio_add_page() if adding really succeeded. Check if the page adding succeeded and if not bail out. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal --- drivers/md/raid1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 68a9e2d9985b..8283ef177f6c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1147,7 +1147,10 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio, if (unlikely(!page)) goto free_pages; - bio_add_page(behind_bio, page, len, 0); + if (!bio_add_page(behind_bio, page, len, 0)) { + free_page(page); + goto free_pages; + } size -= len; i++;