aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 441a1c5b897..eacd46bb36b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2325,16 +2325,15 @@ static struct sg_proc_leaf sg_proc_leaf_arr[] = {
2325static int 2325static int
2326sg_proc_init(void) 2326sg_proc_init(void)
2327{ 2327{
2328 int k, mask;
2329 int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr); 2328 int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr);
2330 struct sg_proc_leaf * leaf; 2329 int k;
2331 2330
2332 sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL); 2331 sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL);
2333 if (!sg_proc_sgp) 2332 if (!sg_proc_sgp)
2334 return 1; 2333 return 1;
2335 for (k = 0; k < num_leaves; ++k) { 2334 for (k = 0; k < num_leaves; ++k) {
2336 leaf = &sg_proc_leaf_arr[k]; 2335 struct sg_proc_leaf *leaf = &sg_proc_leaf_arr[k];
2337 mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO; 2336 umode_t mask = leaf->fops->write ? S_IRUGO | S_IWUSR : S_IRUGO;
2338 proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops); 2337 proc_create(leaf->name, mask, sg_proc_sgp, leaf->fops);
2339 } 2338 }
2340 return 0; 2339 return 0;
@@ -2369,16 +2368,15 @@ static ssize_t
2369sg_proc_write_adio(struct file *filp, const char __user *buffer, 2368sg_proc_write_adio(struct file *filp, const char __user *buffer,
2370 size_t count, loff_t *off) 2369 size_t count, loff_t *off)
2371{ 2370{
2372 int num; 2371 int err;
2373 char buff[11]; 2372 unsigned long num;
2374 2373
2375 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) 2374 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
2376 return -EACCES; 2375 return -EACCES;
2377 num = (count < 10) ? count : 10; 2376 err = kstrtoul_from_user(buffer, count, 0, &num);
2378 if (copy_from_user(buff, buffer, num)) 2377 if (err)
2379 return -EFAULT; 2378 return err;
2380 buff[num] = '\0'; 2379 sg_allow_dio = num ? 1 : 0;
2381 sg_allow_dio = simple_strtoul(buff, NULL, 10) ? 1 : 0;
2382 return count; 2380 return count;
2383} 2381}
2384 2382
@@ -2391,17 +2389,15 @@ static ssize_t
2391sg_proc_write_dressz(struct file *filp, const char __user *buffer, 2389sg_proc_write_dressz(struct file *filp, const char __user *buffer,
2392 size_t count, loff_t *off) 2390 size_t count, loff_t *off)
2393{ 2391{
2394 int num; 2392 int err;
2395 unsigned long k = ULONG_MAX; 2393 unsigned long k = ULONG_MAX;
2396 char buff[11];
2397 2394
2398 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) 2395 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
2399 return -EACCES; 2396 return -EACCES;
2400 num = (count < 10) ? count : 10; 2397
2401 if (copy_from_user(buff, buffer, num)) 2398 err = kstrtoul_from_user(buffer, count, 0, &k);
2402 return -EFAULT; 2399 if (err)
2403 buff[num] = '\0'; 2400 return err;
2404 k = simple_strtoul(buff, NULL, 10);
2405 if (k <= 1048576) { /* limit "big buff" to 1 MB */ 2401 if (k <= 1048576) { /* limit "big buff" to 1 MB */
2406 sg_big_buff = k; 2402 sg_big_buff = k;
2407 return count; 2403 return count;