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:48:00 +0000 (12:48 +0200)
commit443c9d522397511a4328dc2ec3c9c63c73049756
treea842aa9a91403a1656cb3de0076dc3bc32e54b32
parent272dc775a52f2b0d0d8e844e77fefa7df8ebc653
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