2024-01-08 01:45:57

by Yang Li

[permalink] [raw]
Subject: [PATCH -next] fs: Fix type mismatch for pos variable

The 'pos' variable within __cachefiles_prepare_write() and related
functions is intended to store the return value from vfs_llseek(),
which is of loff_t type. However, it was incorrectly declared as
an unsigned long long, which is an unsigned type and cannot store
negative error values returned by vfs_llseek().

This patch corrects the type of 'pos' variable to loff_t, ensuring
that error codes are properly handled and facilitating proper type
conversion from the cachefiles_inject_read_error function.

Signed-off-by: Yang Li <[email protected]>
---
fs/cachefiles/io.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c
index bb19b8bcf2e8..3da2b2e261da 100644
--- a/fs/cachefiles/io.c
+++ b/fs/cachefiles/io.c
@@ -521,8 +521,9 @@ int __cachefiles_prepare_write(struct cachefiles_object *object,
bool no_space_allocated_yet)
{
struct cachefiles_cache *cache = object->volume->cache;
- unsigned long long start = *_start, pos;
+ unsigned long long start = *_start;
size_t len = *_len;
+ loff_t pos;
int ret;

/* Round to DIO size */
--
2.20.1.7.g153144c