From patchwork Thu Apr 20 10:04:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13218305 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 4EDB5C77B73 for ; Thu, 20 Apr 2023 10:06:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E07E1900009; Thu, 20 Apr 2023 06:06:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB76B900002; Thu, 20 Apr 2023 06:06:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7FEC900009; Thu, 20 Apr 2023 06:06:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B5E0B900002 for ; Thu, 20 Apr 2023 06:06:10 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 839E94018E for ; Thu, 20 Apr 2023 10:06:10 +0000 (UTC) X-FDA: 80701338900.08.BB0E40D Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf01.hostedemail.com (Postfix) with ESMTP id B865A40018 for ; Thu, 20 Apr 2023 10:06:08 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681985168; 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=JEWZ0q+3UU4e/xJ535DpLwytA+nRHdzwucl5bbd0W0gLOq2GKR2d4fbgw2jGYkFdWUL3sq zPTB+EsC2uFzTPa8GuF11zOHGKcVF8vLf6aAqju/6ffsoLDA9+H74qWlEEfkF4taq6uynU m476x8n5UOYuBFa0cGYjAbST6CyMKmg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.128.53 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681985168; a=rsa-sha256; cv=none; b=uyu5bR1y2+uYzp0ou5vmWrn5YkmFdPDXSWg0Gn/iIy9YNunYAw8ie+zk/h5RkIpDPG5D7n VSxdwwIGuFX7XeKKMszzOu5BjnEXFEVGYyW6AOL4dDQwgY69zUAqNYgheMEERxOdOWeoR2 XEdkPlrXLObFxW7duUc3ODNMnoFMQHM= Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-3f17b967bfbso14829115e9.1 for ; Thu, 20 Apr 2023 03:06:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681985168; x=1684577168; 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=bndG0+UJkKXapkWS/Aoa8q2PE81zkArWhHyqUs1R15t4r+oyER19ok7WPN2Lmcafwq jzWPqn0VcPUIVi+JmA9mBEfl2VUrclEPQUlgUz83dsMsFLmyLuXD8FKtjlatqLLONazZ WVqKE4zyMFg3/BiZibqalynJOSiTaYU+O1QssKwLRS/ivS5LA8Osd62yYUwjQ1alnLsY dHYo1xAlwy/a4fWcDiJLooXxJOJzdenelHQuXBw+MO5p91ZP8LyCyQuUcGoWvSFzULDt s0PWc6hOtFp82fg/H5hzjee75Uq/c5k3niov2VH4zkCJXNLTS/u+zABLJYqH/gG67BAi FwAw== X-Gm-Message-State: AAQBX9fHnvPsSF+0dclou7K/XGkCsR9Edn8vM18H5ZyzT6R7SE+bHHZJ yaNXncxdXB7rjyKQvPkVVL0= X-Google-Smtp-Source: AKy350bW2EgyTCeppAYbGJgJ4MBVKwGKy3Cxhhh/Q4CkNUysK8MiWFufZI+smKPXyAJBB06Awe3bOQ== X-Received: by 2002:a5d:6a11:0:b0:2f6:661:c03c with SMTP id m17-20020a5d6a11000000b002f60661c03cmr996930wru.28.1681985168177; Thu, 20 Apr 2023 03:06:08 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-208.dynamic.mnet-online.de. [62.216.205.208]) by smtp.googlemail.com with ESMTPSA id l11-20020a5d674b000000b0030276f42f08sm201410wrw.88.2023.04.20.03.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 03:06:07 -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 v4 15/22] md: check for failure when adding pages in alloc_behind_master_bio Date: Thu, 20 Apr 2023 12:04:54 +0200 Message-Id: <20230420100501.32981-16-jth@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230420100501.32981-1-jth@kernel.org> References: <20230420100501.32981-1-jth@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: j6d8wtyyohmg15ss3rjznnz88dcjx3op X-Rspamd-Queue-Id: B865A40018 X-HE-Tag: 1681985168-944807 X-HE-Meta: U2FsdGVkX1/3jSr3E23iOgOZZLrGjaVEeIAW/DCLkV0rVtYxu6Nns7hgg62ZqZU6hS9RDYcSFp+d1Ku47gEslx6BqSGxZvri7Dm5+mL/Uj4CBoEdnvYPYbvN8i7V/Kl4cUFsCtg150S5evFVBv7eEqg8p0CCZ0lIoCKMpcUnt0G5MjqjfOyLT2cDdtbQhvej17LSYFF0XZCe9eJ2w6Xg8fqHHXHEGOAi1DTKY1vOdd2OsCHbz4NafmLI6WJU2jh9d8i+vrcKfJTXvJaQphrKSWgSWpHaOcfw9hQcUk+WGzJiMr7Eios8tu9EnzvMa3mlAoKCQYXtQ2uu3nAXOun6c2yy0uMNMg8w9oSt45P0tRH6Nf9WIdVhl4PraGIl2u5LCRqK+X1DU//bM3/jxeUtMC1ZJOIBblj4B2Xs3sQ3xrmyfGsi0MiJBzc2xUN/mzyEMhkaOI43/Eejhr90fzYhuLyI1WlTYfxKVCNn5VQDkskob7+VeS2wSAj0LKbjRv2w+9x1+Q2t1KxV4yd8TLWsOpTVRPtnXTVg+zdaG+Qv/ynQ/S74vCIuDZiJyL0+J9HIE4w8GG1r9tXj/SEJWZxXt5E9lfmNm3oi0h8cRHedyAOsnW3kpG3KKIQ8AcOHsjJppT5sxt83RIPH8GwqSVNDV5fQDYdvF+oZPsr5M55PDzjVvEmhCFn6FP8TAoHwFAr2DQGYapHJ6EV8crhtNWOjqq6f2mlHSyCZYj3+oo2rADin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.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++;