[PATCH] staging: zcache: make sure client id is valid

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

 



Signed-off-by: Yuanhan Liu <yuanhan.liu@xxxxxxxxxxxxxxx>
---
 drivers/staging/zcache/zcache-main.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 52b43b7..fb68af6 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -68,10 +68,14 @@ static struct zcache_client zcache_clients[MAX_CLIENTS];
 
 static inline uint16_t get_client_id_from_client(struct zcache_client *cli)
 {
+	uint16_t cli_id;
+
 	BUG_ON(cli == NULL);
 	if (cli == &zcache_host)
 		return LOCAL_CLIENT;
-	return cli - &zcache_clients[0];
+	cli_id = cli - &zcache_clients[0];
+	BUG_ON(cli_id > MAX_CLIENTS);
+	return cli_id;
 }
 
 static struct zcache_client *get_zcache_client(uint16_t cli_id)
-- 
1.7.7.6

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux