]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
libceph: make free_choose_arg_map() resilient to partial allocation
authorTuo Li <islituo@gmail.com>
Sat, 20 Dec 2025 18:11:49 +0000 (02:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2026 15:31:17 +0000 (16:31 +0100)
commitc4c2152a858c0ce4d2bff6ca8c1d5b0ef9f2cbdf
treec404b4d926ee6e5ab707ac47a9def6599bf9d410
parent6c6cec3db3b418c4fdf815731bc39e46dff75e1b
libceph: make free_choose_arg_map() resilient to partial allocation

commit e3fe30e57649c551757a02e1cad073c47e1e075e upstream.

free_choose_arg_map() may dereference a NULL pointer if its caller fails
after a partial allocation.

For example, in decode_choose_args(), if allocation of arg_map->args
fails, execution jumps to the fail label and free_choose_arg_map() is
called. Since arg_map->size is updated to a non-zero value before memory
allocation, free_choose_arg_map() will iterate over arg_map->args and
dereference a NULL pointer.

To prevent this potential NULL pointer dereference and make
free_choose_arg_map() more resilient, add checks for pointers before
iterating.

Cc: stable@vger.kernel.org
Co-authored-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Tuo Li <islituo@gmail.com>
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ceph/osdmap.c