From patchwork Thu Mar 30 10:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13193874 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 01603C761AF for ; Thu, 30 Mar 2023 10:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BE95900002; Thu, 30 Mar 2023 06:44:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 970186B0075; Thu, 30 Mar 2023 06:44:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 810E1900002; Thu, 30 Mar 2023 06:44:53 -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 734626B0074 for ; Thu, 30 Mar 2023 06:44:53 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 34D141A0887 for ; Thu, 30 Mar 2023 10:44:53 +0000 (UTC) X-FDA: 80625231666.30.9182BC9 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by imf28.hostedemail.com (Postfix) with ESMTP id 1A5BFC0017 for ; Thu, 30 Mar 2023 10:44:50 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=WlOcPPg6; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf28.hostedemail.com: domain of "prvs=446327cdf=johannes.thumshirn@wdc.com" designates 216.71.153.141 as permitted sender) smtp.mailfrom="prvs=446327cdf=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680173091; 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=8xturZmyswgVjBaYoCYw3BEHPK427U7V7Y+R3cQKPzc=; b=UeyC+puL3GncvpM/bmUlhzQLsWQ3uSQtC+fT6SYZ7TCzqb2z4GrHJcJfVuLxK8lNzkptQ0 wekx5/1t2Xz8s32yvKJJTTsxPwomnbUVYK1YAk1fOzcUpLfFzStQgnJBO+vNC5e0XNY2kD 79OnlnWNmcji80ac+1HccbeZrZKyMVQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=WlOcPPg6; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf28.hostedemail.com: domain of "prvs=446327cdf=johannes.thumshirn@wdc.com" designates 216.71.153.141 as permitted sender) smtp.mailfrom="prvs=446327cdf=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680173091; a=rsa-sha256; cv=none; b=PTlUdVc11iPN13Ydb+tGkRxIyTrfdGmvXT9VBz4X3OixygP3WFDiuoPjoLEPq8fLYz3KZ5 SAAqTVQkQSDqEvSdyB3pTmuIUMsl1c7X8YrV81o726/tFZePrCWTpnnD24fz04Xzkp/Cz1 xh11ug9m1sXlFgd8W0pO2YMPfIBmU+U= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1680173091; x=1711709091; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WuVso3FIWpTS9t16blIu0lxfhGfBw7QOq0E/ZSZkofY=; b=WlOcPPg6+i+9B+/RYW4JrjSuMBn+t3tqi9J5yXIqk0Le0u2rNSbzDNDN 3ODDJdWaWe7WGdJmhwSDYsDY97urDh0fNhMZzPJP9yGYdva5eqsrho0NC m71F0Y1XL0/oFDMbJSYP0BF2nY/SgYtxEscDYAKRNaRV82IO/BTN71Wgu GLCxHnMUPQLPqCvruN/jF1s7DeI2UpbNG1rGBUULSbB/Aar5kYTrwEsrA d52jVanPxHjTBDNbk4VRpxyOAXHGVKG/bE8COCiP9gQyAjh3H4uC02XbN KlCPpcdYuCHM2fdSNwAnGA/Ol6ZRFm3z8eMYTkRFoDLbuh8eR0DJ/XxT4 Q==; X-IronPort-AV: E=Sophos;i="5.98,303,1673884800"; d="scan'208";a="231853963" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 Mar 2023 18:44:50 +0800 IronPort-SDR: P7RyHr5Ng/cpjgbo+hYFIJ0BYTe42f/XYl0fDs5e6AYK1bLjlyxKKvUBzrYzSZKv4zkjy4XNqN pu+GQ80qkTDRAD1hxjvEv7B8OzMG9e0M3/pBoFP+0FYG4LoVkDqMHySagqS8dfwEhGUHOBBTLi yRXh91t8INPhZbHCjbwOIGYcZhGpSum2+DmE5a8YECNcW+1IQmShrkc/qFSLFs2ioeoNw9El2B 5ejjc2WJKUjLqGCGSRbVGBYCnlJ2hzyJ62t3dxKeU0MBXPI+YUGrkyTcMUwhoktE+2mAAU9oej U7g= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 Mar 2023 02:55:17 -0700 IronPort-SDR: xbv9CWFcSC1Bzpr8BamikP+86dncbp6oACJBXmhmSmN1KLO1tjzjSUny6VIcaXoUQyq5sWcuL0 lQBuIK9Qs8v6PE4kuNsKWptmdAB94A57UA5HBiwUoF/UZUfY5X3vAWQoHSh0h+S/n670fLweqX xwW8OqqSonBv72abzryYNSV2io841vwnNZJ8IY+0p5wqBENYMfSLK+JpFOg4uVtqcWWbcuN9UN kEpt44p6/oIeo1ie9PLw+xd46a5i05H2OEhI1oKUgM+t3BiQfepTKLv5GkNzpVe2yAChE6w07e +JY= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Mar 2023 03:44:48 -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 , Damien Le Moal Subject: [PATCH v2 15/19] md: check for failure when adding pages in alloc_behind_master_bio Date: Thu, 30 Mar 2023 03:43:57 -0700 Message-Id: <07ae41b981f1b5f8de80a3f0a8ab2f34034077a6.1680172791.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1A5BFC0017 X-Stat-Signature: u9kwc1gi65z1eeum7zkb7s9i5wbgyau3 X-HE-Tag: 1680173090-469816 X-HE-Meta: U2FsdGVkX1+SqByR9rUSTLRFKY45v8kpn4TqfXq+1pItp6Pp9111Iy+r4islc/XJb6TwT6bA7Jc/t4Z/vp1Ser+wVXu7Crz/fXxrmtJrR/0zYLC7cujnv14ixkaAXK+TddNqEN7ZlQ2hHqwVmel6yIYAnsZ3dWgonbBbJ/S6GInuOF6CrfWvaIIUebv5t2buGgMvK8t5YksjB3y+DEj093wCTeyOnP+PcqmByB2d2Lp+LX3nIvka4oKfljmkJKUxczT6lH558gch1W7bm69drz4vOOgzAWrlDXTGndXmU0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+hPD2IX2CexP+LU5ryN66va9lAxEto35sZV4jNClkQ== 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++;