1
0
Fork 0

blk-mq: add bounds check on tag-to-rq conversion

We need to check for a valid index before accessing the array
element to avoid accessing invalid memory regions.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

Modified by Jens to drop the unlikely(), and make the fall through
path be having a valid tag.

Signed-off-by: Jens Axboe <axboe@fb.com>
hifive-unleashed-5.1
Hannes Reinecke 2016-03-15 12:03:28 -07:00 committed by Jens Axboe
parent 2b88551711
commit 4ee86babe0
1 changed files with 4 additions and 1 deletions

View File

@ -544,7 +544,10 @@ EXPORT_SYMBOL(blk_mq_abort_requeue_list);
struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)
{
return tags->rqs[tag];
if (tag < tags->nr_tags)
return tags->rqs[tag];
return NULL;
}
EXPORT_SYMBOL(blk_mq_tag_to_rq);