[PATCH] blk-mq: sanity check for retrieving request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
-- 
1.8.5.6

--
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



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux