提交 34bd9c1c 编写于 作者: B Bart Van Assche 提交者: Jens Axboe

block: Fix off-by-one errors in blk_status_to_errno() and print_req_error()

This was detected by the smatch static analyzer.

Fixes: commit 2a842aca ("block: introduce new block status code type")
Signed-off-by: NBart Van Assche <bart.vanassche@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 e0fc443a
......@@ -169,7 +169,7 @@ int blk_status_to_errno(blk_status_t status)
{
int idx = (__force int)status;
if (WARN_ON_ONCE(idx > ARRAY_SIZE(blk_errors)))
if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
return -EIO;
return blk_errors[idx].errno;
}
......@@ -179,7 +179,7 @@ static void print_req_error(struct request *req, blk_status_t status)
{
int idx = (__force int)status;
if (WARN_ON_ONCE(idx > ARRAY_SIZE(blk_errors)))
if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
return;
printk_ratelimited(KERN_ERR "%s: %s error, dev %s, sector %llu\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册