From patchwork Wed May 31 11:50:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13262051 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 6ADCDC77B73 for ; Wed, 31 May 2023 11:51:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C9726B009B; Wed, 31 May 2023 07:51:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 079876B009C; Wed, 31 May 2023 07:51:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E83C58E0002; Wed, 31 May 2023 07:51:34 -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 D89FD6B009B for ; Wed, 31 May 2023 07:51:34 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9D99A14035A for ; Wed, 31 May 2023 11:51:34 +0000 (UTC) X-FDA: 80850385308.18.CF51E9C Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by imf10.hostedemail.com (Postfix) with ESMTP id 873E9C0023 for ; Wed, 31 May 2023 11:51:32 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b="e+3h/c5l"; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.hostedemail.com: domain of "prvs=508ef2a02=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=508ef2a02=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685533892; 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=4wltjMlOzsPDRwIgGzzKckeo7q3CC1AtmBW5BIRqZZc=; b=ESqHthbwXX9CyJru6Bgqukd3Sm6Mc0g83mVBod4YOdjrkdw/NpoPQi+XHqzDk+PBwhNhVd 6wmCSvKSjNQ6Em7lYKYJbJC7BzlicxKjxE5iLMFZHxXCjar5/sTgYYMuhA6c+VyPdRJGCj 9lDzyBT0V9O1Jz1+qb6vYJPSkGCSPUo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b="e+3h/c5l"; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.hostedemail.com: domain of "prvs=508ef2a02=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=508ef2a02=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685533892; a=rsa-sha256; cv=none; b=EDTQWZE1XM3YRY4KCrvEoiepzYLp5SEAZWOjlDKyH+LrNf9dByNR7PkskvImnrL9Akie63 LuQkY3sr99MvOH/loGXdDY48ekVSa3n+NmKmO4zOwENztZUY7lVBP/bdNrdnHKmIlQXAlO n6iMAStHvxW0mhY7OgGyC+SASAk4nVk= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1685533892; x=1717069892; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ea2jSAo1rrcM5ItwZsgG7lxFamxzjCiiRPLmWH2vTf4=; b=e+3h/c5lnfwZWZdQgchdUaawY0qdxXli2Fm1EFO8BRXJYEWjz/xA/KOq ZVLhoina92KoURvboGuWx6GEFzjjR2xbmBcges+24KcmV3+4iGHyay3Wv YD0zos1WPUTRLA3a0R7fxppG3m5EdCxNSV9YpRSDG20Soc+ac/dgcdDLD PEdlzFlLUYyeKrNIxL7+lIyweUa0pnbXG3G9DyXaGS2IoKcO1+qdavKyb LNmavho0nrF3AuuGLvVI+gbuF4hIVfn9V5xj2Xhj2uXRtWOfwDTNo6h2Q HVY12h6oUcsGwK5DrPPj+H0J7u3jDs9eCf4fjr0oNczIXpVe/rf4v8ND+ A==; X-IronPort-AV: E=Sophos;i="6.00,207,1681142400"; d="scan'208";a="230207465" 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; 31 May 2023 19:51:31 +0800 IronPort-SDR: rMnIWjOcL7+dGL1rYGO5MHf6oBC+ti3R5hzz9a2p8JUZXwsFEDKYLVdsUzN4vzIZCqdxhrhquI crJ3dUfS/A4kAzx3FqcZRkdlzu8PGecBj+98aKMUunYxNGH3Tg5zMLbBPaV/2P/aEaxa/6kZ/M ckOT945xjjrDEeS+EKDbLj6uiLIvrqQY9YBANerDKjD4ot4PKDAVPMRmMI/guZOfSReHwIMpYo l4WKKlPkv/Q9/nzF7x8ly4ze9nTtB3IfuEythQ3y/rbqmfMtkAmuEOwD4tj6AV/us/7Hbo691t qIw= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 31 May 2023 04:06:24 -0700 IronPort-SDR: Z6zZ5moCZAo8HyghcdM8Wh0qvfaCT2LiPQW+ewVuXAv+zyl3VKWafiSq2yJXvM/A54CkcTJN+V kRVbq0irr40y+MWSjgjPIzREhnBw/QeLa6OkO6LV2aSFbCYOSOdgOKC/mj9w510XzxJvNJ+Ppc bKsq1lcjXCfe5M8sYfeB+boMuGe7XuwZ5WTGw2/M7CwC8jX4gUJEv1IB/iHxsG6xSoVSNEIkFI s8y0GfyXNSKO/vqm5AA9muwlpfgMinBcH8LoI7yFQZewBeLk1GwYOBtK16jZm+Elw8Aj2MWMYn WJY= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 31 May 2023 04:51:29 -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 , Mikulas Patocka , gouha7@uniontech.com, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v7 13/20] md: check for failure when adding pages in alloc_behind_master_bio Date: Wed, 31 May 2023 04:50:36 -0700 Message-Id: <827aa12d44ebf3f50b41b47f5cedc0f80179f2c1.1685532726.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 873E9C0023 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: sj8u4rgzh6t7cfyg8ygepaxckcu73tym X-HE-Tag: 1685533892-898279 X-HE-Meta: U2FsdGVkX18GAItMCtSMJzM9lNgQ1Ar0uOuE9MKflWIRZpINpAelCneRQrgQzHnEMNfjGK0e2zp/A/ww02vuRON01SNWRKz3fDYSrk1YxaG0kOPv/T2g8k1Dt4sbeD9IMqLaVtZA6z8SToymYUcvgTJ2MoQqD+YJEf1IH2bOI1bLC4T3Utzl9rJLWHIXofnqbzUl/MnOOSm2V4qqFJeSrTxJiEFkK/m+0+2qrZLOVmFnYU/RNeDyRySbjraBVHNZ4ToKy8Q1EyrusGorgLPiW6b7QfEoscBDh89OaQIe9p4iA6QNv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x7ceEARanicwqtTEIYco0p8FTDDzeZ94RtHbD/4AhCOq/Ebo6Y9IVhnPDkjkFnAJoLtYAthBEA2v3VEeTKPtHTEkLzmL3OzDlks= 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: Christoph Hellwig Acked-by: Song Liu 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++;