From: chm Date: Wed, 8 May 2013 06:18:00 +0000 (+0800) Subject: vpu_service: add reg_size check on reg_init X-Git-Tag: firefly_0821_release~7135 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c8097eb220345e6f39c6894fb9915476f0c365e7;p=firefly-linux-kernel-4.4.55.git vpu_service: add reg_size check on reg_init --- 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;