]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ceph: fix memory leak in ceph_direct_read_write()
authorIlya Dryomov <idryomov@gmail.com>
Fri, 6 Dec 2024 16:32:59 +0000 (17:32 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 16 Dec 2024 22:25:44 +0000 (23:25 +0100)
commit66e0c4f91461d17d48071695271c824620bed4ef
treef86c971bfd358e57cd9817644ec293ca854bada9
parent9abee475803fab6ad59d4f4fc59c6a75374a7d9d
ceph: fix memory leak in ceph_direct_read_write()

The bvecs array which is allocated in iter_get_bvecs_alloc() is leaked
and pages remain pinned if ceph_alloc_sparse_ext_map() fails.

There is no need to delay the allocation of sparse_ext map until after
the bvecs array is set up, so fix this by moving sparse_ext allocation
a bit earlier.  Also, make a similar adjustment in __ceph_sync_read()
for consistency (a leak of the same kind in __ceph_sync_read() has been
addressed differently).

Cc: stable@vger.kernel.org
Fixes: 03bc06c7b0bd ("ceph: add new mount option to enable sparse reads")
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Markuze <amarkuze@redhat.com>
fs/ceph/file.c