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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94054C6379F for ; Mon, 13 Feb 2023 21:01:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 77A8B857CA; Mon, 13 Feb 2023 22:01:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 24130857E0; Mon, 13 Feb 2023 22:01:21 +0100 (CET) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8A532857DF for ; Mon, 13 Feb 2023 22:01:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=whitebox@nefkom.net Received: from frontend03.mail.m-online.net (unknown [192.168.6.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4PFxb21PDPz1s94m; Mon, 13 Feb 2023 22:01:18 +0100 (CET) Received: from localhost (dynscan3.mnet-online.de [192.168.6.84]) by mail.m-online.net (Postfix) with ESMTP id 4PFxb20Y12z1qqlR; Mon, 13 Feb 2023 22:01:18 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan3.mail.m-online.net [192.168.6.84]) (amavisd-new, port 10024) with ESMTP id 8MnN-JW_uRqB; Mon, 13 Feb 2023 22:01:17 +0100 (CET) X-Auth-Info: Occ07ParaKeaalaL/0UlRBo/JiOBU0OoPEdk9cRLiUKJzsTxiuhaHEi1oM4TfXrU Received: from igel.home (aftr-82-135-86-52.dynamic.mnet-online.de [82.135.86.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 13 Feb 2023 22:01:17 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 220BC2C1B31; Mon, 13 Feb 2023 22:01:17 +0100 (CET) From: Andreas Schwab To: Qu Wenruo Cc: u-boot@lists.denx.de, linux-btrfs@vger.kernel.org Subject: Re: [PATCH] fs: btrfs: limit the mapped length to the original length References: <99e2c01bb0366af9aec7522f7109c74b09c5509d.1676248644.git.wqu@suse.com> X-Yow: I'm GLAD I remembered to XEROX all my UNDERSHIRTS!! Date: Mon, 13 Feb 2023 22:01:17 +0100 In-Reply-To: <99e2c01bb0366af9aec7522f7109c74b09c5509d.1676248644.git.wqu@suse.com> (Qu Wenruo's message of "Mon, 13 Feb 2023 08:37:59 +0800") Message-ID: <87pmadjn4y.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Feb 13 2023, Qu Wenruo wrote: > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 4aaaeab663f5..7d4095d9ca88 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -956,6 +956,7 @@ int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw, > struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; > struct cache_extent *ce; > struct map_lookup *map; > + u64 orig_len = *length; > u64 offset; > u64 stripe_offset; > u64 *raid_map = NULL; > @@ -1047,6 +1048,7 @@ again: > } else { > *length = ce->size - offset; > } > + *length = min_t(u64, *length, orig_len); > > if (!multi_ret) > goto out; I can confirm that this fixes the issue. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."