Skip to contentSkip to conversation

fs: Fix type mismatch for pos variable

PATCH New Yang Li 1 participant 1 message Jan 8, 2024 Cachefiles: fs-cache backend for caching on mounted filesystems

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 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.

---
 fs/cachefiles/io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cachefiles/io.c +2 -1
index bb19b8bcf2e8..3da2b2e261da 100644
@@ -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 */
Signature · 1 line
2.20.1.7.g153144c