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)
committerJens Axboe <axboe@kernel.dk>
Wed, 6 Mar 2024 15:31:54 +0000 (08:31 -0700)
commit93f52fbeaf4b676b21acfe42a5152620e6770d02
treea88d2800745928881702da81773690cc54950722
parente6dfe748f09e37f77437bd337f891f5b57d5d5a2
block: prevent division by zero in blk_rq_stat_sum()

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>
block/blk-stat.c