diff options
author | Bart Van Assche <bart.vanassche@wdc.com> | 2017-06-21 19:55:46 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2017-06-21 20:01:14 +0200 |
commit | 34bd9c1c4f62e936d8865e6442f332cd85bdfc95 (patch) | |
tree | df1aefcbcb80242e1c892866dd3ad1c727d88cf5 /block/blk-core.c | |
parent | block: Declare local symbols static (diff) | |
download | linux-34bd9c1c4f62e936d8865e6442f332cd85bdfc95.tar.xz linux-34bd9c1c4f62e936d8865e6442f332cd85bdfc95.zip |
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 2a842acab109 ("block: introduce new block status code type")
Signed-off-by: Bart 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: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r-- | block/blk-core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 2e02314ea331..3c18ea60cb1c 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -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", |