From c8097eb220345e6f39c6894fb9915476f0c365e7 Mon Sep 17 00:00:00 2001
From: chm <chm@rock-chips.com>
Date: Wed, 8 May 2013 14:18:00 +0800
Subject: [PATCH] vpu_service: add reg_size check on reg_init

---
 arch/arm/plat-rk/vpu_service.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/plat-rk/vpu_service.c b/arch/arm/plat-rk/vpu_service.c
index 8767e19dfc24..5fa902ab3626 100644
--- a/arch/arm/plat-rk/vpu_service.c
+++ b/arch/arm/plat-rk/vpu_service.c
@@ -439,6 +439,10 @@ static vpu_reg *reg_init(vpu_session *session, void __user *src, unsigned long s
 		return NULL;
 	}
 
+	if (size > service.reg_size) {
+		printk("warning: vpu reg size %lu is larger than hw reg size %lu\n", size, service.reg_size);
+		size = service.reg_size;
+	}
 	reg->session = session;
 	reg->type = session->type;
 	reg->size = size;
@@ -807,7 +811,6 @@ static long vpu_service_ioctl(struct file *filp, unsigned int cmd, unsigned long
 			pr_err("error: VPU_IOC_SET_REG copy_from_user failed\n");
 			return -EFAULT;
 		}
-
 		reg = reg_init(session, (void __user *)req.req, req.size);
 		if (NULL == reg) {
 			return -EFAULT;
-- 
2.34.1