]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: prevent division by zero in blk_rq_stat_sum()
authorRoman Smirnov <r.smirnov@omp.ru>
Tue, 5 Mar 2024 13:45:09 +0000 (16:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 11:01:45 +0000 (13:01 +0200)
commit21e7d72d0cfcbae6042d498ea2e6f395311767f8
tree2bcfef14faa16009f7e97dd6b90caad1efb23033
parentbe113e082b65433135b9e85e442fb8c5f0c87534
block: prevent division by zero in blk_rq_stat_sum()

[ Upstream commit 93f52fbeaf4b676b21acfe42a5152620e6770d02 ]

The expression dst->nr_samples + src->nr_samples may
have zero value on overflow. It is necessary to add
a check to avoid division by zero.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/20240305134509.23108-1-r.smirnov@omp.ru
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-stat.c