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)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 26 Jan 2022 19:17:50 +0000 (20:17 +0100)
commit89d43d0551a848e70e63d9ba11534aaeabc82443
treeec5160adc017dd964214e674dea7b004d434374b
parente783362eb54cd99b2cac8b3a9aeac942e6f6ac07
ceph: put the requests/sessions when it fails to alloc memory

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>
fs/ceph/caps.c