ceph: put the requests/sessions when it fails to alloc memory
authorXiubo Li <xiubli@redhat.com>
Wed, 12 Jan 2022 04:29:04 +0000 (12:29 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 1 Feb 2022 16:27:14 +0000 (17:27 +0100)
commit35b092d3b57f47af50b6e5da77bb73fc4e66c704
tree9f1b43048ddd6a669cd845e7c82da38a8ec61923
parent0536379e9d9dd59504a2ccd6338cd87a2eb25653
ceph: put the requests/sessions when it fails to alloc memory

[ Upstream commit 89d43d0551a848e70e63d9ba11534aaeabc82443 ]

When failing to allocate the sessions memory we should make sure
the req1 and req2 and the sessions get put. And also in case the
max_sessions decreased so when kreallocate the new memory some
sessions maybe missed being put.

And if the max_sessions is 0 krealloc will return ZERO_SIZE_PTR,
which will lead to a distinct access fault.

URL: https://tracker.ceph.com/issues/53819
Fixes: e1a4541ec0b9 ("ceph: flush the mdlog before waiting on unsafe reqs")
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ceph/caps.c