Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocfs2: heartbeat: replace simple_strtoul with kstrtoul

simple_strtoul() is deprecated due to ignoring overflows and also requires
clunkier error checking. Replacing with kstrtoul() leads to safer code
and cleaner error checking.

Link: https://lkml.kernel.org/r/20241117215219.4012-1-danielyangkang@gmail.com
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Daniel Yang and committed by
Andrew Morton
08de555a 386ca64d

+12 -9
+12 -9
fs/ocfs2/cluster/heartbeat.c
··· 1535 1535 { 1536 1536 unsigned long bytes; 1537 1537 char *p = (char *)page; 1538 + int ret; 1538 1539 1539 - bytes = simple_strtoul(p, &p, 0); 1540 - if (!p || (*p && (*p != '\n'))) 1541 - return -EINVAL; 1540 + ret = kstrtoul(p, 0, &bytes); 1541 + if (ret) 1542 + return ret; 1542 1543 1543 1544 /* Heartbeat and fs min / max block sizes are the same. */ 1544 1545 if (bytes > 4096 || bytes < 512) ··· 1623 1622 struct o2hb_region *reg = to_o2hb_region(item); 1624 1623 unsigned long tmp; 1625 1624 char *p = (char *)page; 1625 + int ret; 1626 1626 1627 1627 if (reg->hr_bdev_file) 1628 1628 return -EINVAL; 1629 1629 1630 - tmp = simple_strtoul(p, &p, 0); 1631 - if (!p || (*p && (*p != '\n'))) 1632 - return -EINVAL; 1630 + ret = kstrtoul(p, 0, &tmp); 1631 + if (ret) 1632 + return ret; 1633 1633 1634 1634 if (tmp > O2NM_MAX_NODES || tmp == 0) 1635 1635 return -ERANGE; ··· 2138 2136 { 2139 2137 unsigned long tmp; 2140 2138 char *p = (char *)page; 2139 + int ret; 2141 2140 2142 - tmp = simple_strtoul(p, &p, 10); 2143 - if (!p || (*p && (*p != '\n'))) 2144 - return -EINVAL; 2141 + ret = kstrtoul(p, 10, &tmp); 2142 + if (ret) 2143 + return ret; 2145 2144 2146 2145 /* this will validate ranges for us. */ 2147 2146 o2hb_dead_threshold_set((unsigned int) tmp);