From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45C82C7EE23 for ; Tue, 30 May 2023 20:41:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232053AbjE3UlM (ORCPT ); Tue, 30 May 2023 16:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230194AbjE3UlL (ORCPT ); Tue, 30 May 2023 16:41:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93F348E; Tue, 30 May 2023 13:41:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 286156336C; Tue, 30 May 2023 20:41:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86BC1C4339E; Tue, 30 May 2023 20:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685479269; bh=NZg4xbNptwq5J83x4/9FfgWYp2tn6LBMqAKgwyJG6tQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=huQNFFH3zVrLLnm5WPfMAbkQPvxCmvDcAuR9nNKd/g6ZoLU+oubgPMfhcvejhwbMy bRuBct3r6wHKkzYqhqEvGFfCpZYRAuAiT3wzv9jYwpqlslolPQpVoC6l4bkxTW5cgq aHvAkKgwybK+QQl1B0Jilwhzk8yfsI7fuifW9XQTkoKFITI0dXVq6KXEBzrUICZPze PyVOTDar79WsVhr08Ikvo3yCjwDdtgjfVU2jkcBlq4rrXYZPDH8DmVzyUBEoHLrosB Mkru2m9rHaX4pyzYCzA4oMl+/2mViC42oBWSv4cVmV6MbUN1IWMmZVyQlgMZsMsif+ TJLaW7xm4WLyg== Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-4f4db9987f8so275773e87.1; Tue, 30 May 2023 13:41:09 -0700 (PDT) X-Gm-Message-State: AC+VfDyEDKU7ap/F+eqFKI+/1NjSEoNR+a/SpvbbwknSwtcTS2B9K1Wk VX4UKpEIsObbwju0F9EMx+H2XddgdzALxM+QQHA= X-Google-Smtp-Source: ACHHUZ7vuf2vQNikh852gIOeYbs1mAspWrnHLpuRQ0WVk/9d/YVdWPAiSzLnXbcDRj80He113UbugMRuu4yM7AjsQxc= X-Received: by 2002:a2e:a222:0:b0:2af:18a9:782f with SMTP id i2-20020a2ea222000000b002af18a9782fmr4570675ljm.0.1685479267531; Tue, 30 May 2023 13:41:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Song Liu Date: Tue, 30 May 2023 13:40:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 13/20] md: check for failure when adding pages in alloc_behind_master_bio To: Johannes Thumshirn Cc: Jens Axboe , 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, 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, Damien Le Moal Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org On Tue, May 30, 2023 at 8:50=E2=80=AFAM Johannes Thumshirn wrote: > > alloc_behind_master_bio() can possibly add multiple pages to a bio, but i= t > 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 > --- > 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 -=3D len; > i++; > -- > 2.40.1 >