Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6119023pxv; Thu, 29 Jul 2021 07:01:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMSVnL2oSMdQ1dUnfVJiUznlB88IK+tJlJqbUbyP++QqmsUXwszfTDE9CkCM4c8sVQTi1r X-Received: by 2002:a92:c805:: with SMTP id v5mr3510848iln.293.1627567301596; Thu, 29 Jul 2021 07:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627567301; cv=none; d=google.com; s=arc-20160816; b=UCnUd+bBEPyIwlDJRYh9eSJ7EyJFgEiM6PEfX3CCgyLIiXKPNf/hbJf2XuB8u84vpO 6xhMsi8Cytkls2KYqlRd8f2PrxE77YpCvXH4NiExXtGniZoDx1Xugg6Jy/ev1LTNfWf0 3frL7MJX9KxrWETsDAn9gRNRmQXJgoxHH4Kfq4GNSTZ1xUD7JL0BXyxeQ2yI2l1CJhql ECkmYTgVlG2D63QFbxBM1XIuMYu2zrwGa0XHkgXSmTKyeu+k6BwuAnljOFX9GafDPz3e X5YqgTVV1tLhq+llK3xadMASPuKq7MvBAePnZ5MpbtOHHlvRs21uep3eOzjk4HMfw/8B QpJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wov6N4AFKvmi6HsZzAe5Eg++cda6tQgWuDYnTvEbNKo=; b=tb62oBKsyLb4A7SvWi7uKptu9EYv3JdOUk/+kYjUbbFHdHQ6FnHIGXr9PNJuuGVEpm 4G8QCcRZhQMn9m54rmy39BtjSuL08Wj+UCn85XaP7JFyIfXgBy1fzI3X6GOgeKLFtRis g3LCoCkI7iRkTVbbWdalgOk64ShC/+TwvHYiyfL5IYCPAxievXhf40Pp5zoknz2AndJb A/6EJe6aHb8+jk5NTG8nyRrHDTQ03t87J4u6/0bKxhBMQqSJ0oDR9BVcEhevODai7oJ3 wgd9QBgw7Tf4yaQf3zJmlDZp7/EerX4Hv67GF9JKkM9+kNU4SomPuKEXys2Weyx8F4kI bSfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TpLPImrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n23si3609430ion.23.2021.07.29.07.01.29; Thu, 29 Jul 2021 07:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TpLPImrF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238401AbhG2N6S (ORCPT + 99 others); Thu, 29 Jul 2021 09:58:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:48218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237932AbhG2N5o (ORCPT ); Thu, 29 Jul 2021 09:57:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A4E6F60F42; Thu, 29 Jul 2021 13:57:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627567061; bh=4ONx8zleb/J/EZvZr8o+gLi87G4j7rh8wL10QVPWXRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TpLPImrFkSrr82o/Yhs8Z8VvTWPxvq1bZ15G5q/tSBCpfuiNTKuTunejNNckjXCEY D5n49nT2ph919A//d/3lYg0zxhtxzOp4ePN0cAJ/wiMaz7dAdDLP7gYkG1sz3K04wn uwsLZildK4KuOKhRm9m9IhPssK6WhZYQHjE4Gpew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , "Leizhen (ThunderTown)" , "Darrick J. Wong" , "Matthew Wilcox (Oracle)" , Sasha Levin Subject: [PATCH 5.4 18/21] iomap: remove the length variable in iomap_seek_data Date: Thu, 29 Jul 2021 15:54:25 +0200 Message-Id: <20210729135143.490445612@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210729135142.920143237@linuxfoundation.org> References: <20210729135142.920143237@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit 3ac1d426510f97ace05093ae9f2f710d9cbe6215 ] The length variable is rather pointless given that it can be trivially deduced from offset and size. Also the initial calculation can lead to KASAN warnings. Signed-off-by: Christoph Hellwig Reported-by: Leizhen (ThunderTown) Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Sasha Levin --- fs/iomap/seek.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fs/iomap/seek.c b/fs/iomap/seek.c index c04bad4b2b43..c61b889235b3 100644 --- a/fs/iomap/seek.c +++ b/fs/iomap/seek.c @@ -186,27 +186,23 @@ loff_t iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops) { loff_t size = i_size_read(inode); - loff_t length = size - offset; loff_t ret; /* Nothing to be found before or beyond the end of the file. */ if (offset < 0 || offset >= size) return -ENXIO; - while (length > 0) { - ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops, - &offset, iomap_seek_data_actor); + while (offset < size) { + ret = iomap_apply(inode, offset, size - offset, IOMAP_REPORT, + ops, &offset, iomap_seek_data_actor); if (ret < 0) return ret; if (ret == 0) - break; - + return offset; offset += ret; - length -= ret; } - if (length <= 0) - return -ENXIO; - return offset; + /* We've reached the end of the file without finding data */ + return -ENXIO; } EXPORT_SYMBOL_GPL(iomap_seek_data); -- 2.30.2