dm stats: check for and propagate alloc_percpu failure
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 16 Mar 2023 06:55:06 +0000 (14:55 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Mar 2023 10:49:30 +0000 (12:49 +0200)
commita42180dd361584816bfe15c137b665699b994d90
tree432ee2646ba93c9d83e756e3aa017a551ca18e3b
parent7c64e839585eac8048bf67b1c6dcb7a5ca189a2e
dm stats: check for and propagate alloc_percpu failure

commit d3aa3e060c4a80827eb801fc448debc9daa7c46b upstream.

Check alloc_precpu()'s return value and return an error from
dm_stats_init() if it fails. Update alloc_dev() to fail if
dm_stats_init() does.

Otherwise, a NULL pointer dereference will occur in dm_stats_cleanup()
even if dm-stats isn't being actively used.

Fixes: fd2ed4d25270 ("dm: add statistics support")
Cc: stable@vger.kernel.org
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-stats.c
drivers/md/dm-stats.h
drivers/md/dm.c