public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yang Li <yang.lee@linux.alibaba.com>
To: dhowells@redhat.com
Cc: linux-cachefs@redhat.com, linux-kernel@vger.kernel.org,
	Yang Li <yang.lee@linux.alibaba.com>
Subject: [PATCH -next] fs: Fix type mismatch for pos variable
Date: Mon,  8 Jan 2024 09:45:36 +0800	[thread overview]
Message-ID: <20240108014536.43971-1-yang.lee@linux.alibaba.com> (raw)

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 <yang.lee@linux.alibaba.com>
---
 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


                 reply	other threads:[~2024-01-08  1:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240108014536.43971-1-yang.lee@linux.alibaba.com \
    --to=yang.lee@linux.alibaba.com \
    --cc=dhowells@redhat.com \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox