This repository was archived by the owner on Jul 3, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
drivers/media/platform/msm/vidc Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 1212 */
1313
1414#define CREATE_TRACE_POINTS
15+ #define MAX_SSR_STRING_LEN 10
1516#include "msm_vidc_debug.h"
1617#include "vidc_hfi_api.h"
1718
@@ -130,17 +131,33 @@ static int trigger_ssr_open(struct inode *inode, struct file *file)
130131
131132static ssize_t trigger_ssr_write (struct file * filp , const char __user * buf ,
132133 size_t count , loff_t * ppos ) {
133- u32 ssr_trigger_val ;
134- int rc ;
134+ unsigned long ssr_trigger_val = 0 ;
135+ int rc = 0 ;
135136 struct msm_vidc_core * core = filp -> private_data ;
136- rc = sscanf (buf , "%d" , & ssr_trigger_val );
137- if (rc < 0 ) {
137+ size_t size = MAX_SSR_STRING_LEN ;
138+ char kbuf [MAX_SSR_STRING_LEN + 1 ] = {0 };
139+
140+ if (!count )
141+ goto exit ;
142+
143+ if (count < size )
144+ size = count ;
145+
146+ if (copy_from_user (kbuf , buf , size )) {
147+ dprintk (VIDC_WARN , "%s User memory fault\n" , __func__ );
148+ rc = - EFAULT ;
149+ goto exit ;
150+ }
151+
152+ rc = kstrtoul (kbuf , 0 , & ssr_trigger_val );
153+ if (rc ) {
138154 dprintk (VIDC_WARN , "returning error err %d\n" , rc );
139155 rc = - EINVAL ;
140156 } else {
141157 msm_vidc_trigger_ssr (core , ssr_trigger_val );
142158 rc = count ;
143159 }
160+ exit :
144161 return rc ;
145162}
146163
You can’t perform that action at this time.
0 commit comments