From patchwork Tue May 30 15:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13260560 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 E2D3AC7EE2F for ; Tue, 30 May 2023 15:50:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83292900011; Tue, 30 May 2023 11:50:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E2BF900005; Tue, 30 May 2023 11:50:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AA80900011; Tue, 30 May 2023 11:50:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5C764900005 for ; Tue, 30 May 2023 11:50:17 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D2053A0252 for ; Tue, 30 May 2023 15:50:16 +0000 (UTC) X-FDA: 80847358032.09.E9B8980 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by imf10.hostedemail.com (Postfix) with ESMTP id A8E57C0025 for ; Tue, 30 May 2023 15:50:13 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=lQcti6TN; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.hostedemail.com: domain of "prvs=507b913ec=johannes.thumshirn@wdc.com" designates 216.71.153.144 as permitted sender) smtp.mailfrom="prvs=507b913ec=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685461814; 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=kfbXVXnOIfMtfpOW0KwQK8XZeszf1+haBQT/gEejogo=; b=N4bSrthEzIsP83AEamz9Onmilx5ONtwoH7/Z5rRdgOc89BuC7J3NiN6qAyZN+GfxS6I9+Y LtaQdARvf+TE2lHewL0uySuVSxfApjpZSjvlCUvCmpawoTq+H4vcfwT3y+TtiVU+DIBJDV Wt4cBHss92lAccrLJQsBoY4BJUDQkdw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=lQcti6TN; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.hostedemail.com: domain of "prvs=507b913ec=johannes.thumshirn@wdc.com" designates 216.71.153.144 as permitted sender) smtp.mailfrom="prvs=507b913ec=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685461814; a=rsa-sha256; cv=none; b=yviw2h1sR4PnWDFB1B/GsB+V8suH5crGIQPV5cLA7p8aCyhmef0S9RmPNlqviQ4Bgl4i75 orb/Ggxtv8ic2Mx/5B8JxDGkRa11vByS1byBD0Sxo1WMNepFaUyssnCFVnbnOCgEl5PA+S d1l5FUEi2JQJTHcUXSyH04Jfsasxem4= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1685461814; x=1716997814; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VBiHAYrZ5iVLErIRk58IVnEcVkubX6MqVTAomfOuNwY=; b=lQcti6TNhi0HCVUjGBjdCoykBkN8Ccf9+xsrK2rU5pdmYctQflR9eoH7 05YripkVW2SpzJhhscKT6Zc3ko1d6DMOj/BMOlmMZlTdWN/A/Wf3zA/Ff xbkufl3dotQ5QR4S5CZH7mtyw/svMXhtW1fy1/En6iZHSFAzWgrQhq7Cv g+iOAQV14Kxrx7mhAGzUybt1q+9hFTV52c+0y46M6RdfEvCnP8RX1qree uqDteo4riDyqsXimpuuHgpdSnNI4agySVPNv9OqJG43lYUOJ+AoOnOo/N tLU4c3fsY1Q/NSyN+Ll1JeHmkWyy4oBuqjLUgj4JrTTZjoe2qqz/4D74m w==; X-IronPort-AV: E=Sophos;i="6.00,204,1681142400"; d="scan'208";a="231905748" 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 May 2023 23:50:12 +0800 IronPort-SDR: o55uNe0K/XM7tTZStlrdORG2MjVtzg82kaEObBbVGrdqlYfHLU2cqk8t0NBk0dtXxLfKQq20uw M+H5uoPSAD5y/dIFCqvYF8IccCol25mzT2uXZScOx/91yZIqM1F2nW5tmliRRS6Ph/RNtdssYu B6xwsMBu9/ywvJs+xgUDLFgkKeGEsu1yzgGqa8ZE12RlhADjBYCoU0CbCzZbJFIzhndVy5Molx j7ykFf9NKgyJgNfyj19WLwBC2I4zJag2bnJihBURE563xIloCEQC4MweMZLbALcCVxBvxxe7Rx 86g= 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; 30 May 2023 07:59:24 -0700 IronPort-SDR: P8Y6Jd83vQweumNav4silCK78F18+npfP53U6otRJi27bXYVZjQeG19QgfdDPNWr1dSjMk/mR0 TdQwe1yI9lQT8scICxHJ6QWWNvtw6CpvMEfGKX0/h2/HRnwwlFzCTEOhpHvRwXqArmvKCIqw33 ppmdUhNH/kHH580hO75tFT3x/8Uyc3S+cBMv20/BBkhaZLKkAVgh0pxoEQ8eaQU2CR7VRKPGtI xQvmwMzb+rhKJ4KrnyzbkU6q4fYwpSUwIQMfpbXadsUNzjaagJ7+TEz8B0KEm1VNYW+RFH1x1t ltA= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 30 May 2023 08:50:06 -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 , gouhao@uniontech.com, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v6 13/20] md: check for failure when adding pages in alloc_behind_master_bio Date: Tue, 30 May 2023 08:49:16 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: A8E57C0025 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 66ryt5wj9exizsxa6gaeanno4wj1sd4t X-HE-Tag: 1685461813-133429 X-HE-Meta: U2FsdGVkX1+5n/TcIt6SD8G+CdSngidYszpvelZIJzgw2utu6KFzRdzfmyytdhiPeZus4Qdj5hzNuLrzsYN7u+WlAlxOxDx4S4zzjADRokINivWcpDQVxyUUzr+Gd2t96l+MA732KOZ+793YJUSmNbEBP9APA/xKc0snuJjGIo5hWb3oJ0fmAqEQXK8B5Pf9v1VREsh1Uz6c35sMExLywcXa8jsr/ykZlXhu6HoBof5pnJ1TM9qMM5UIBDeBzLA+jWkZRv28g/FRvjQQ2cXInzoCXEyt6r2jni8LZZEqfHIPTUN/oWWsDa6Mh4EgqS/tZZQOjzLfU+lrTkI905CGbFpjd1xNVmP7cuLg5841bpzx2gGmVpCmbo2TNnuZ261Mjp7cDmYFIcsYmVfhEHrMFgB8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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 Acked-by: Song Liu Reviewed-by: Christoph Hellwig --- 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++;