Staging: silicom: use kstrtoint_from_user()
The main problem with the hand rolled code was that there weren't any range checks so you could corrupt memory by writing too much data to the proc file. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Daniel Cotey <puff65537@bansheeslibrary.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e4c536b72f
commit
82e6bb0398
1 changed files with 10 additions and 22 deletions
|
@ -8071,20 +8071,13 @@ int
|
||||||
set_bypass_wd_pfs(struct file *file, const char *buffer,
|
set_bypass_wd_pfs(struct file *file, const char *buffer,
|
||||||
unsigned long count, void *data)
|
unsigned long count, void *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
char kbuf[256];
|
|
||||||
bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
|
bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
|
||||||
|
int timeout;
|
||||||
|
int ret;
|
||||||
|
|
||||||
unsigned int timeout = 0;
|
ret = kstrtoint_from_user(buffer, count, 10, &timeout);
|
||||||
char *timeout_ptr = kbuf;
|
if (ret)
|
||||||
|
return ret;
|
||||||
if (copy_from_user(&kbuf, buffer, count)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeout_ptr = kbuf;
|
|
||||||
timeout = atoi(&timeout_ptr);
|
|
||||||
|
|
||||||
set_bypass_wd_fn(pbp_device_block, timeout);
|
set_bypass_wd_fn(pbp_device_block, timeout);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
@ -8712,18 +8705,13 @@ int
|
||||||
set_wd_autoreset_pfs(struct file *file, const char *buffer,
|
set_wd_autoreset_pfs(struct file *file, const char *buffer,
|
||||||
unsigned long count, void *data)
|
unsigned long count, void *data)
|
||||||
{
|
{
|
||||||
char kbuf[256];
|
|
||||||
bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
|
bpctl_dev_t *pbp_device_block = (bpctl_dev_t *) data;
|
||||||
u32 timeout = 0;
|
int timeout;
|
||||||
char *timeout_ptr = kbuf;
|
int ret;
|
||||||
|
|
||||||
if (copy_from_user(&kbuf, buffer, count)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeout_ptr = kbuf;
|
|
||||||
timeout = atoi(&timeout_ptr);
|
|
||||||
|
|
||||||
|
ret = kstrtoint_from_user(buffer, count, 10, &timeout);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
set_wd_autoreset_fn(pbp_device_block, timeout);
|
set_wd_autoreset_fn(pbp_device_block, timeout);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|
Loading…
Add table
Reference in a new issue