Skip to content

Commit

Permalink
net/ipv4: replace simple_strtoul with kstrtoul
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
eldad authored and davem330 committed May 20, 2012
1 parent b37f4d7 commit 413c27d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -3408,9 +3408,15 @@ struct ip_rt_acct __percpu *ip_rt_acct __read_mostly;
static __initdata unsigned long rhash_entries;
static int __init set_rhash_entries(char *str)
{
ssize_t ret;

if (!str)
return 0;
rhash_entries = simple_strtoul(str, &str, 0);

ret = kstrtoul(str, 0, &rhash_entries);
if (ret)
return 0;

return 1;
}
__setup("rhash_entries=", set_rhash_entries);
Expand Down
8 changes: 7 additions & 1 deletion net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3462,9 +3462,15 @@ extern struct tcp_congestion_ops tcp_reno;
static __initdata unsigned long thash_entries;
static int __init set_thash_entries(char *str)
{
ssize_t ret;

if (!str)
return 0;
thash_entries = simple_strtoul(str, &str, 0);

ret = kstrtoul(str, 0, &thash_entries);
if (ret)
return 0;

return 1;
}
__setup("thash_entries=", set_thash_entries);
Expand Down
8 changes: 7 additions & 1 deletion net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2173,9 +2173,15 @@ void udp4_proc_exit(void)
static __initdata unsigned long uhash_entries;
static int __init set_uhash_entries(char *str)
{
ssize_t ret;

if (!str)
return 0;
uhash_entries = simple_strtoul(str, &str, 0);

ret = kstrtoul(str, 0, &uhash_entries);
if (ret)
return 0;

if (uhash_entries && uhash_entries < UDP_HTABLE_SIZE_MIN)
uhash_entries = UDP_HTABLE_SIZE_MIN;
return 1;
Expand Down

0 comments on commit 413c27d

Please sign in to comment.