From: Bart Van Assche <bart.vanassche@wdc.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, Christoph Hellwig <hch@lst.de>,
"Bart Van Assche" <bart.vanassche@wdc.com>,
Hannes Reinecke <hare@suse.com>, Ming Lei <ming.lei@redhat.com>
Subject: [PATCH 2/3] block: Fix off-by-one errors in blk_status_to_errno() and print_req_error()
Date: Wed, 21 Jun 2017 10:55:46 -0700 [thread overview]
Message-ID: <20170621175547.21692-3-bart.vanassche@wdc.com> (raw)
In-Reply-To: <20170621175547.21692-1-bart.vanassche@wdc.com>
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>
---
block/blk-core.c | 4 ++--
1 file 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",
--
2.13.1
next prev parent reply other threads:[~2017-06-21 17:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-21 17:55 [PATCH 0/3] Fixes for kernel v4.13 Bart Van Assche
2017-06-21 17:55 ` [PATCH 1/3] block: Declare local symbols static Bart Van Assche
2017-06-21 17:55 ` Bart Van Assche [this message]
2017-06-21 17:55 ` [PATCH 3/3] blk-mq: Make it safe to quiesce and unquiesce from an interrupt handler Bart Van Assche
2017-06-22 10:32 ` Ming Lei
2017-06-21 18:01 ` [PATCH 0/3] Fixes for kernel v4.13 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170621175547.21692-3-bart.vanassche@wdc.com \
--to=bart.vanassche@wdc.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox