From patchwork Tue May 2 10:19:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13229206 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 9877BC77B7E for ; Tue, 2 May 2023 17:43:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 326D46B007E; Tue, 2 May 2023 13:43:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B0716B0080; Tue, 2 May 2023 13:43:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08CA16B0081; Tue, 2 May 2023 13:43:18 -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 EA6106B007E for ; Tue, 2 May 2023 13:43:18 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BDB8981340 for ; Tue, 2 May 2023 17:43:18 +0000 (UTC) X-FDA: 80746036476.17.54F9F79 Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by imf05.hostedemail.com (Postfix) with ESMTP id DA80D101648 for ; Tue, 2 May 2023 13:18:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=miKmQNAV; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf05.hostedemail.com: domain of "prvs=479dded8d=johannes.thumshirn@wdc.com" designates 68.232.141.245 as permitted sender) smtp.mailfrom="prvs=479dded8d=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683033519; 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=mLz58nOU27a6t/084l1Lf6vRkGjs+YDPAFvRSQ2t0Y8=; b=Mi8xo178RIunJLsZ6XNADboMwsnW1IlgH2+g2buDowbIf2GxeTqh5nrcEuR6x109gZhKIJ btIEkwUZr/Wyxp2ejQFNSGr9i54mgaV+BSmUsALr31Ngvn2i57Gp1uUzA2nos4TEerz35u kW+taOemcPWD0hLA37hYzqVHUP7piiQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=miKmQNAV; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf05.hostedemail.com: domain of "prvs=479dded8d=johannes.thumshirn@wdc.com" designates 68.232.141.245 as permitted sender) smtp.mailfrom="prvs=479dded8d=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683033519; a=rsa-sha256; cv=none; b=fYs/xn618vUijhtiE3PwRV0cEajs7zUaQW3VEl43VaLiegXqXaSHiLcwkTQd4syRBzAeOF /kW2tIlexh5oRz9o5xfUPY0qF/ZTb53x49pXYq14/5Ro70hNtKE+3veFWtE8LQwQWaPWqN 2JlAnCUffCRDrZOeSkRXlgzqVfgihIg= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1683033520; x=1714569520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DzvJ6wZ3Sui4RZ9TAlD4OlMyP4gDTchzDlmODiRTaA8=; b=miKmQNAVvFyKtmMDQvRKhYfiTAIPO3iz2ibDWKql+vEmheze2OFTyz0l kqKgoNBWOM75xW95KoWmmfX7UgUpwkcy1T2w+swa8ZFONKhZW2CGZaCIS JkkRxvDb9V2qy0OCJzkkOW5y+BlW71S8lqgz9U9bViNzxo02UnD4M7bDS lExfaCY6sK6R+wTm5dESMKFXaE3k8sCverLPxYjOjMZwgUESTvtYTSrDu pRJiabGt98xGHT6+jAFtCUAfOFQ6i28SFLB6OTPw6vL1s14OymtfxP1/X yip9fZv3ohkawNuukL18pQRbKHzOB69uL6Tz8BYEX9k2tATKNCd6Hjy3Y g==; X-IronPort-AV: E=Sophos;i="5.99,243,1677513600"; d="scan'208";a="341747203" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 May 2023 18:21:35 +0800 IronPort-SDR: zwChcrq9mVA0fYQ0MaY1MQZe9qp2BkImyz/0vJHZp6gzqEsshXslKcZPtNqYQX0fMTLAixeV5T lmsGz3WRIIMrldN9X6uyqawEwZpzIM7awJ5rJzjJoyNm/zpDJkX6E5YCSZqARgYmkw//lpzuk3 9frvEGlnJlYYvt1Rpf/yuokDtGKJpMjcCXfPCzhhqaDhnJ9dNtCBfTQbZPArZ7R7T+sfx3BywT IxvT7uMfp4p8qzS+ntgIUUdF3n4vSUR1IWz15ZbRlja2gLjuFCMfjYimx9XRBS4yhlHRESN8Yl fbk= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 May 2023 02:31:23 -0700 IronPort-SDR: uGIw254wyz5xW63y6mKPruYBxsDCJBiWJn5HyxXEKlHH3a6WQB95MJD2gL1U37MsE73pDlkDfH XrAQKE0o1trWaMuwmkCjZxReOE6bQKTuwcjttjZub9Fo2NWOrlg+l+x9Li4fpCvU8smOVgdBJe iX9LTVSMXZH6O+ImhKiOGTSlNSVog/dyr5RquJMBmwgwChPCFkHcE06ByPGE2sBKs5rW/DQtzK T5Xxpb54D4Yuz40YIDXaPoJ+wQXNcche+tu3/6iWe/RHtJ7xSAUbzgyNSPsRVFjywOIFjhKDZt 2iU= WDCIronportException: Internal Received: from myd008205.ad.shared (HELO localhost.localdomain) ([10.225.1.100]) by uls-op-cesaip02.wdc.com with ESMTP; 02 May 2023 03:21:32 -0700 From: Johannes Thumshirn To: "axboe @ kernel . dk" Cc: agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@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, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v5 13/20] md: check for failure when adding pages in alloc_behind_master_bio Date: Tue, 2 May 2023 12:19:27 +0200 Message-Id: <20230502101934.24901-14-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230502101934.24901-1-johannes.thumshirn@wdc.com> References: <20230502101934.24901-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 X-Stat-Signature: o1agsjuicudu1ws9y5nojh86wuh395ek X-Rspam-User: X-Rspamd-Queue-Id: DA80D101648 X-Rspamd-Server: rspam07 X-HE-Tag: 1683033488-733986 X-HE-Meta: U2FsdGVkX197SItrXYSfG6OGg1EbCfUG5Cbx2mLijJ0tPJqNcfmxls7iSiigRaXm1DPtY1wlvPnoFhI+K9tKbicVLT48meocO+cgIJjGJLSTZTH8MOBXX4GMRV7F3Z8ytEWMuUG2OsV3L87xnh9cvUy79E6+cXWgd/dsfOmvWDBputWrHaYCfKX8iXeec+MoNCYjzhB85Usx5iW1uXECgi0Tjgb6LBi+ycU3dlxFUJZ9Ip6TgvtL2SrH6jaNzNL1VpWYEtK4RGoI2bYBvRwGZeljjzT/8o9gaKjW4ZBlyI6MYR9rfCXn7925X8cZK1VKIirZpIuDGLGfSN6enEV4ON17HUgJhVo/pBBmVkymVbZewLbHZdgUxR2/e+nRFlVR4WK1XlNbcy5izw3NRAdRpmLl0ptvsPt7SwIkgZi6FIYl3LC1P40KpYQDST9ShpTCEzEdzWfQcSIgXMYKHxzrXYPIXpBr/32IhZx9vlLzCwC72oTZIbtgIPnvxRL59oylsOKvOO2NmIue0hdv/PcItv/YXq123ymE7F0aOtO5WSU3Q2Xt6+0XwbO3obrlPR1rdxwK6J4flfzjJ3X1f2xqiSFISYw7UT1+HXPGm/n9DZ2iWi9QnovDcmv+3WNulDoeyrt7TmF5iVOxewcMkw5aA6hjIA+drC5aaXawEUt6STODQZXJij+mRtxXbVy4NWPec3fpI+DgNOfykjo1H0i3Oi+J4KI4krHXWfIDsI833Ri8xuSHUJ1UAh6X5j99Nnf5VcifO1r4noDCK5Gj+vgMKtwop8q5zE2GKEObpfnXLPaigYsTdzt7+znkn+E5mzyXCJF1VM/I6LsWgFjwF//2YZ69R0ZWxeoXTDUzounXh+weNTdCbLNkNYixFRzB8jdKBkGu+Zq89xWATx4B0OXVEmC1t70QALQjHVBv9Ye+EvHs4n4+veANfKr+LiIVX15n71Q/e1m3hwmdUur+vMj f4wgcXdF W/ybf340ApSG14Bevrx1aEcUCI9uyB5xOEpj1jYC8nlgo97XHwQKLW+B2ovGQHFR15r07AHzgew/LUkgN+psSCPXP8d5472tKWENRUI8rziGwFPwRytX4u5/8iUffaItrDbYHyYwQp67efwtbI585+R8CdzDMD2XUYXFG8qFRf9iwx4SSGF4PNYINAb+8UlD6d2fnuKBXiWCOfWVlRgCsK2VyyH4mx9QG0Uo3 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. Reviewed-by: Damien Le Moal Signed-off-by: Johannes Thumshirn --- 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++;