Skip to content

Commit 413c27d

Browse files
eldaddavem330
authored andcommitted
net/ipv4: replace simple_strtoul with kstrtoul
Replace simple_strtoul with kstrtoul in three similar occurrences, all setup handlers: * route.c: set_rhash_entries * tcp.c: set_thash_entries * udp.c: set_uhash_entries Also check if the conversion failed. Signed-off-by: Eldad Zack <eldad@fogrefinery.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b37f4d7 commit 413c27d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

net/ipv4/route.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3408,9 +3408,15 @@ struct ip_rt_acct __percpu *ip_rt_acct __read_mostly;
34083408
static __initdata unsigned long rhash_entries;
34093409
static int __init set_rhash_entries(char *str)
34103410
{
3411+
ssize_t ret;
3412+
34113413
if (!str)
34123414
return 0;
3413-
rhash_entries = simple_strtoul(str, &str, 0);
3415+
3416+
ret = kstrtoul(str, 0, &rhash_entries);
3417+
if (ret)
3418+
return 0;
3419+
34143420
return 1;
34153421
}
34163422
__setup("rhash_entries=", set_rhash_entries);

net/ipv4/tcp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3462,9 +3462,15 @@ extern struct tcp_congestion_ops tcp_reno;
34623462
static __initdata unsigned long thash_entries;
34633463
static int __init set_thash_entries(char *str)
34643464
{
3465+
ssize_t ret;
3466+
34653467
if (!str)
34663468
return 0;
3467-
thash_entries = simple_strtoul(str, &str, 0);
3469+
3470+
ret = kstrtoul(str, 0, &thash_entries);
3471+
if (ret)
3472+
return 0;
3473+
34683474
return 1;
34693475
}
34703476
__setup("thash_entries=", set_thash_entries);

net/ipv4/udp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,9 +2173,15 @@ void udp4_proc_exit(void)
21732173
static __initdata unsigned long uhash_entries;
21742174
static int __init set_uhash_entries(char *str)
21752175
{
2176+
ssize_t ret;
2177+
21762178
if (!str)
21772179
return 0;
2178-
uhash_entries = simple_strtoul(str, &str, 0);
2180+
2181+
ret = kstrtoul(str, 0, &uhash_entries);
2182+
if (ret)
2183+
return 0;
2184+
21792185
if (uhash_entries && uhash_entries < UDP_HTABLE_SIZE_MIN)
21802186
uhash_entries = UDP_HTABLE_SIZE_MIN;
21812187
return 1;

0 commit comments

Comments
 (0)