diff options
| author | Christian Brauner <[email protected]> | 2024-11-11 11:31:42 +0000 |
|---|---|---|
| committer | Christian Brauner <[email protected]> | 2024-11-11 13:39:39 +0000 |
| commit | a4b2923376be062a243ac38762212a38485cfab1 (patch) | |
| tree | 428c625aa1057da5def490483792064d73c5caad /fs/cachefiles/interface.c | |
| parent | Merge patch series "Random netfs folio fixes" (diff) | |
| parent | netfs/fscache: Add a memory barrier for FSCACHE_VOLUME_CREATING (diff) | |
| download | kernel-a4b2923376be062a243ac38762212a38485cfab1.tar.gz kernel-a4b2923376be062a243ac38762212a38485cfab1.zip | |
Merge patch series "fscache/cachefiles: Some bugfixes"
Zizhi Wo <[email protected]> says:
This patchset mainly includes 5 fix patches about fscache/cachefiles.
The first patch fixes an issue with the incorrect return length, and the
fourth patch addresses a null pointer dereference issue with file.
* patches from https://lore.kernel.org/r/[email protected]:
netfs/fscache: Add a memory barrier for FSCACHE_VOLUME_CREATING
cachefiles: Fix NULL pointer dereference in object->file
cachefiles: Clean up in cachefiles_commit_tmpfile()
cachefiles: Fix missing pos updates in cachefiles_ondemand_fd_write_iter()
cachefiles: Fix incorrect length return value in cachefiles_ondemand_fd_write_iter()
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'fs/cachefiles/interface.c')
| -rw-r--r-- | fs/cachefiles/interface.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 35ba2117a6f6..3e63cfe15874 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c @@ -327,6 +327,8 @@ static void cachefiles_commit_object(struct cachefiles_object *object, static void cachefiles_clean_up_object(struct cachefiles_object *object, struct cachefiles_cache *cache) { + struct file *file; + if (test_bit(FSCACHE_COOKIE_RETIRED, &object->cookie->flags)) { if (!test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) { cachefiles_see_object(object, cachefiles_obj_see_clean_delete); @@ -342,10 +344,14 @@ static void cachefiles_clean_up_object(struct cachefiles_object *object, } cachefiles_unmark_inode_in_use(object, object->file); - if (object->file) { - fput(object->file); - object->file = NULL; - } + + spin_lock(&object->lock); + file = object->file; + object->file = NULL; + spin_unlock(&object->lock); + + if (file) + fput(file); } /* |
