ocfs2: replace deprecated simple_strtol with kstrtol
authorDaniel Yang <danielyangkang@gmail.com>
Fri, 15 Nov 2024 08:00:17 +0000 (00:00 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 13 Jan 2025 04:21:07 +0000 (20:21 -0800)
simple_strtol() ignores overflows and has an awkward interface for error
checking.  Replace with the recommended kstrtol function leads to clearer
error checking and safer conversions.

Link: https://lkml.kernel.org/r/20241115080018.5372-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>
fs/ocfs2/cluster/heartbeat.c

index 467127e361be64b75a16c35c9ad0b008660878be..724350925aff33f149ea1939c0ded934b752546f 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (C) 2004, 2005 Oracle.  All rights reserved.
  */
 
+#include "linux/kstrtox.h"
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/jiffies.h>
@@ -1778,8 +1779,8 @@ static ssize_t o2hb_region_dev_store(struct config_item *item,
        if (o2nm_this_node() == O2NM_MAX_NODES)
                return -EINVAL;
 
-       fd = simple_strtol(p, &p, 0);
-       if (!p || (*p && (*p != '\n')))
+       ret = kstrtol(p, 0, &fd);
+       if (ret < 0)
                return -EINVAL;
 
        if (fd < 0 || fd >= INT_MAX)