Skip to content

Commit 26fd840

Browse files
aristeutorvalds
authored andcommitted
device_cgroup: stop using simple_strtoul()
Convert the code to use kstrtou32() instead of simple_strtoul() which is deprecated. The real size of the variables are u32, so use kstrtou32 instead of kstrtoul Signed-off-by: Aristeu Rozanski <aris@redhat.com> Cc: Dave Jones <davej@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Li Zefan <lizefan@huawei.com> Cc: James Morris <jmorris@namei.org> Cc: Pavel Emelyanov <xemul@openvz.org> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Cc: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5b7aa7d commit 26fd840

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

‎security/device_cgroup.c‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
361361
int filetype, const char *buffer)
362362
{
363363
const char *b;
364-
char *endp;
365-
int count;
364+
char temp[12]; /* 11 + 1 characters needed for a u32 */
365+
int count, rc;
366366
struct dev_exception_item ex;
367367

368368
if (!capable(CAP_SYS_ADMIN))
@@ -405,8 +405,16 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
405405
ex.major = ~0;
406406
b++;
407407
} else if (isdigit(*b)) {
408-
ex.major = simple_strtoul(b, &endp, 10);
409-
b = endp;
408+
memset(temp, 0, sizeof(temp));
409+
for (count = 0; count < sizeof(temp) - 1; count++) {
410+
temp[count] = *b;
411+
b++;
412+
if (!isdigit(*b))
413+
break;
414+
}
415+
rc = kstrtou32(temp, 10, &ex.major);
416+
if (rc)
417+
return -EINVAL;
410418
} else {
411419
return -EINVAL;
412420
}
@@ -419,8 +427,16 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
419427
ex.minor = ~0;
420428
b++;
421429
} else if (isdigit(*b)) {
422-
ex.minor = simple_strtoul(b, &endp, 10);
423-
b = endp;
430+
memset(temp, 0, sizeof(temp));
431+
for (count = 0; count < sizeof(temp) - 1; count++) {
432+
temp[count] = *b;
433+
b++;
434+
if (!isdigit(*b))
435+
break;
436+
}
437+
rc = kstrtou32(temp, 10, &ex.minor);
438+
if (rc)
439+
return -EINVAL;
424440
} else {
425441
return -EINVAL;
426442
}

0 commit comments

Comments
 (0)