On 03/15/2016 08:01 PM, Jens Axboe wrote: > On 03/15/2016 01:21 AM, Hannes Reinecke wrote: >> We need to check for a valid index before accessing the array >> element to avoid accessing invalid memory regions. >> >> Signed-off-by: Hannes Reinecke <hare@xxxxxxxx> >> --- >> block/blk-mq.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/block/blk-mq.c b/block/blk-mq.c >> index 56c0a72..4ea87d5 100644 >> --- a/block/blk-mq.c >> +++ b/block/blk-mq.c >> @@ -544,6 +544,8 @@ EXPORT_SYMBOL(blk_mq_abort_requeue_list); >> >> struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, >> unsigned int tag) >> { >> + if (unlikely(tag >= tags->nr_tags)) >> + return NULL; >> return tags->rqs[tag]; >> } >> EXPORT_SYMBOL(blk_mq_tag_to_rq); > > I like adding the check, but I think we should kill the unlikely and > just make it: > > if (tag < tags->nr_tags) > return tags->rqs[tag]; > > return NULL; > > instead. I'll apply it as such. > yeah, I had a discussion about the viability of the 'unlikely' flag given modern compilers. No consensus was reached, so I left it in. Removing it is fine by me, too. Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare@xxxxxxx +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html