1
0
Fork 0

bq27441: New kernel, stricter rules for memory

zero-colors
Lars Ivar Miljeteig 2018-06-20 12:40:08 +02:00 committed by Grzegorz-J
parent 26b9acd8db
commit 66a84c60a7
1 changed files with 11 additions and 1 deletions

View File

@ -9,6 +9,7 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/debugfs.h>
#include <linux/uaccess.h>
#include <linux/power/bq27xxx_battery.h>
@ -740,11 +741,20 @@ static ssize_t debugfs_store_ext_byteorword(struct file *fp, const char __user *
u8 data[2] = {0, 0};
int index;
u32 dataout;
unsigned long bytesleft;
char kernelbuf[21] = {0};
if (!di)
return -EIO;
ret = sscanf(userbuf, "%u", &dataout);
if (count > 10)
return -EINVAL;
bytesleft = copy_from_user(kernelbuf, userbuf, 20);
if (bytesleft)
return -EINVAL;
ret = sscanf(kernelbuf, "%u", &dataout);
if (ret != 1 || dataout > 65535)
return -EINVAL;