Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1053966pxv; Thu, 22 Jul 2021 21:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu0ejBuQ6srkx3XNW0o/PKnyx0PbcznAIsKnmM90egBewUffqgRveoVQ3oz8yVRQptMFXC X-Received: by 2002:a17:906:38c8:: with SMTP id r8mr2931457ejd.172.1627012952859; Thu, 22 Jul 2021 21:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627012952; cv=none; d=google.com; s=arc-20160816; b=eBI5D8TkaXx09ToPx9zXJJjfOrlCBJQZ0YOfCBd0ifIHnk5x0tvguwly4so3qk45Vk CpPaKse7Wo5YYz8BuIRrYvDlLCFxFFBjThAKD7hXlKxJ3W6+BtvWiUA8Zeqy/pdCw7+r TmWj9NaC+RThnx5RfWwMVcN/Ts+Jo7Qzop+0NGCrYRNgFXr9PWRJ0K48pa5Iw/fkBNrP cgxAyEfVO7u2uLjGodXj8TF4ovF1qntjiLFsnz0tl+IolOTi3tr6AztfCmcjnYzE72DK L6ayc7A5MazG1PeEezQUd/qkia6XmZD5q+AWXKnWNIQ5o3NEZQgT0GUbt3KEGNk5+RzT kZBQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xhpHqMFARk3MbGFk7IYU9o5Uck9JjvMuDwvzTLJb260=; b=0tqRWM5NL62imz43zJP09OZenoA4pvw5ZOQkZBub0mRNiWLRb2dkpxpWQL/iHwSGjV 3oShzLc3zZjR2M2xjIiwMWiMXlt6HeqUQ4PdjWgVwzex0rDI5E6+tQSSok3EHoNMo+Ml yzovAcgmGVPvjYa0tXvRC8oRY7qv2Ns6D8x5gqpPArwL43M8voiOWULFYwh0Fq4s2V4w HExbbd33eOT1GajkOZu08x6KLKDEjOBV+JZPodC7uuwXGLpQU2UgWHjw+XyHSB5lYcqD ebn7Hek9A9Jc7yCQJExN1g7+TYKSfJ/chdXwkW/O6durelG/V+LtNcCzPQoHN7BWxPGu k7ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ic2nJKIr; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si29884469ejl.292.2021.07.22.21.02.09; Thu, 22 Jul 2021 21:02:32 -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=@kernel.org header.s=k20201202 header.b=ic2nJKIr; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234039AbhGWDRf (ORCPT + 99 others); Thu, 22 Jul 2021 23:17:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:37534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233743AbhGWDRL (ORCPT ); Thu, 22 Jul 2021 23:17:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30B6760F36; Fri, 23 Jul 2021 03:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627012665; bh=NBwycyZpcWFpXMuqm52Myl7XVI6DIA0P1rTPJSPJshM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ic2nJKIrCBwu3sfucijcpkEErlDZrR//hMefpeHrlWl4CI1cAQwW0iYJGL80rbU4q sze5ctQpWDJR47y/GrjdBjcS0vaYg4nXDj7XR3hW4YcsGMrR4Vr8WKgz64e2awIsr/ /i44iKTd8D9o8UEE9b9GzM3aoEncJq3WmrYoWQO7j5KVHgDdGb7FskPmscO+IwL8Qx qS7IHAlqOfffgGqk3D5RTJlHrjUnSD4C5buEfkc+SdG5VbKg8ygwGdZtoxVXmjvW7G PW0VfVvenMbpG+EY6i5yGxuVjYwwbosB5ChoYscD6M4EkVy7tcvnvpiYusRsXmURb7 CD17QKXMUBHGw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Leizhen , "Darrick J . Wong" , Matthew Wilcox , Sasha Levin , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 17/19] iomap: remove the length variable in iomap_seek_data Date: Thu, 22 Jul 2021 23:57:18 -0400 Message-Id: <20210723035721.531372-17-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723035721.531372-1-sashal@kernel.org> References: <20210723035721.531372-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 dab1b02eba5b..50b8f1418f26 100644 --- a/fs/iomap/seek.c +++ b/fs/iomap/seek.c @@ -83,27 +83,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