From patchwork Wed Mar 29 17:06:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13192964 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 2E7BBC6FD18 for ; Wed, 29 Mar 2023 17:07:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC5C4280008; Wed, 29 Mar 2023 13:07:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4F45280001; Wed, 29 Mar 2023 13:07:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A1AA280008; Wed, 29 Mar 2023 13:07:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8581D280001 for ; Wed, 29 Mar 2023 13:07:06 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 657781C5FCA for ; Wed, 29 Mar 2023 17:07:06 +0000 (UTC) X-FDA: 80622566052.25.94DDE25 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by imf21.hostedemail.com (Postfix) with ESMTP id 26B941C0023 for ; Wed, 29 Mar 2023 17:07:03 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=EgCBgxyM; spf=pass (imf21.hostedemail.com: domain of "prvs=445a3f1bb=johannes.thumshirn@wdc.com" designates 216.71.154.45 as permitted sender) smtp.mailfrom="prvs=445a3f1bb=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680109624; 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:dkim-signature; bh=7+bIXF2fTdL9cWuJDdsLfpimmTL4CGHXMEA6wqfKprk=; b=ZrgziG+boz3wzJxTXhcTyTfxDy4l/d0AQ9tTNiUB8ngL7Cw+IDTO+jVKt+5/OMiN17v2lb k8uYousODQbPYpdM0QtY0o4EY3lNsQ4de2JP7LT3NbxsmxaK7Q1AdN9vYylT97pA8rAjQN Gvgv91RrYT6H3564qsOiBC4xUPhHpvg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=EgCBgxyM; spf=pass (imf21.hostedemail.com: domain of "prvs=445a3f1bb=johannes.thumshirn@wdc.com" designates 216.71.154.45 as permitted sender) smtp.mailfrom="prvs=445a3f1bb=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680109624; a=rsa-sha256; cv=none; b=7w0fu85VGuOLa5UFY8QGtfHUgt7flvvkw5KfaS5bgqtFdAtViF78ZBms/RgtRJGutfQwcB JMSDeSijz02eAAsBeyBq0D90izOPQy56X6jVG94HYfN/iIoE5d3TxD6ZMhrEcdEvlfqh9k cPonwpPyNrowIP7vDRV8Y0ca4Zdxfns= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1680109624; x=1711645624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iZ22wN2mWRIC3IC0ve2ktcoeKHTOmDQMcv9pQZAGU1o=; b=EgCBgxyMlR4FYs0ukJJSuddfO6RaDKuG7lf6849jDs9tnqcjFsz7TwKG TrZTkTRP9uEnoQxMpig3Go+XjhkRKdBfVhpMlUkuV9BXFM/ZVM+OVsUjw gVYUpShwjJxJb/6PWQSSPY2lSYzpAWCiGZJqLQB79N9KskFKaEugSCWq5 0Q2bHUPJRHVIpVAC7MRszt9IMPS+ySZz949lkklMIOCixdQnCdK2MMZTX C4BubeApmq8golWZHXjlOZnOYuXNKETgnWQ8Wau+eSOMPwnbfnzktWD6M 6IW0fVfPc1V/mW6ahXICrGQevAqIrqY02Aa8s14dNSE80B3zzttzzGMWV w==; X-IronPort-AV: E=Sophos;i="5.98,301,1673884800"; d="scan'208";a="226807095" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Mar 2023 01:07:03 +0800 IronPort-SDR: CUw4RwikyCOGiyorA97RhV8Uxj9M3K7WrRlJNKAyMy/YrkKVh80qU0OVX0StaxZQbzuMj550mB N9nxoq1zfoPtWsSyI2sElNVxtvol/w8nPBvYvtfGoO0wA/uj6OyxbRVetsXziCIxYUvO2aMyZu rIKCC8seHzcRciFX+BFnkcxRCLkyn5m8aiKcjO0StPPPjNHc/t+HASXhQlQJRA5tpFzWyrbpx9 nHOlHTcJaRcgD+wQqVYXgyMmNKMKfzlm4l0pA8NMsD2tlNlnrYLzSt4JEoZ8O7aAnJJIKJBYlV AAQ= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 29 Mar 2023 09:23:13 -0700 IronPort-SDR: QenhUoCI4gCJokChYIRTxR/AmeR3KMt0i9Ax1ZUEuOE55BQNPmd9r5SN16Ch8MkiJkIpZRNt6I qUqUWECToDJ2WJWUpGDVQEaikqB6uT7pLfViFCRAcappfhtVNCd/noIg/ffVrtgTFQXaHZa2+9 qvf0zarO4BdnnsxEfFyvXa+MLW55EgGw+iqxyMy9lk11OGTrZhPXyK+RBxeQV8dZU6/1rjQcdM 2AqTxj/IU9pm/2z5SJvCrEd9J0iojU5OMLtUdmwaC41nSBL3uay8UbzV0sr/esbq/6zIeGVC7M m7k= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Mar 2023 10:07:02 -0700 From: Johannes Thumshirn To: Jens Axboe Cc: Christoph Hellwig , Hannes Reinecke , Chaitanya Kulkarni , Damien Le Moal , Ming Lei , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, dm-devel@redhat.com, Song Liu , linux-raid@vger.kernel.org, Mike Snitzer , Matthew Wilcox , Dave Kleikamp , jfs-discussion@lists.sourceforge.net, cluster-devel@redhat.com, Bob Peterson , Andreas Gruenbacher , David Sterba , linux-btrfs@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 15/19] md: check for failure when adding pages in alloc_behind_master_bio Date: Wed, 29 Mar 2023 10:06:01 -0700 Message-Id: <76f5748e386870c034b46e919101a878b87a79bf.1680108414.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 26B941C0023 X-Stat-Signature: e9bq955numjchqa15rie5m3p64sj6a4i X-Rspam-User: X-HE-Tag: 1680109623-778320 X-HE-Meta: U2FsdGVkX18ldf2ql+p3IguCl19nufe25ifTTFQQ+gv+mATHV3z+dYjNhSl3J7VrjaRG4ZZCb0zK3ea61mLkZd9JYBekb4gcT4cpPJfDNV8yweneL1O1gEN582JDoxba+/OI+07wL4xh1L5tssPTwxWhiscwtHHMPysL71EnAo0QQ2qmeoxPzR6Ha93ZzaQ4O6QPfNIKgXd7xsI2dVKwTpADYFg3hWHgxT5iOG5krNAGDDRLeR5/XQHRNjPM1LThS+x8Eiq2tDsGicG++3E5R0gau5pcOQvqlNxIObFtqf6MuIGDA4qEehqX0M2WDA8k8bB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CszDSuGsW4x4aB7okAundHdBbV1V 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: 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 68a9e2d9985b..bd7c339a84a1 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1147,7 +1147,8 @@ 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)) + goto free_pages; size -= len; i++;