kernel/file_cache: fix VMCache object leak

Fixes #18039.

Change-Id: Ia3cda69f91e56efb36931a97028378ec3ceb2100
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5801
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
(cherry picked from commit 8be7c1aa58)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5778
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
X512 2022-11-05 19:16:40 +09:00 committed by waddlesplash
parent 36c5d2644d
commit 483f78eb36

View File

@ -959,8 +959,10 @@ cache_prefetch_vnode(struct vnode* vnode, off_t offset, size_t size)
VMCache* cache;
if (vfs_get_vnode_cache(vnode, &cache, false) != B_OK)
return;
if (cache->type != CACHE_TYPE_VNODE)
if (cache->type != CACHE_TYPE_VNODE) {
cache->ReleaseRef();
return;
}
file_cache_ref* ref = ((VMVnodeCache*)cache)->FileCacheRef();
off_t fileSize = cache->virtual_end;