]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm-shrinkers-add-scan-interface-for-shrinker-debugfs-fix
authorRoman Gushchin <roman.gushchin@linux.dev>
Thu, 2 Jun 2022 00:56:22 +0000 (17:56 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 20 Jul 2022 00:15:03 +0000 (20:15 -0400)
improve typing, fix arg count checking

Link: https://lkml.kernel.org/r/YpgKttTowT22mKPQ@carbon
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Acked-by: Muchun Song <songmuchun@bytedance.com>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shrinker_debug.c

index e25114e0c41cb005d81c47b16d7031e89ce5c502..12026472daaecefa5aecb7df16827b2fed93c7d9 100644 (file)
@@ -110,21 +110,21 @@ static ssize_t shrinker_debugfs_scan_write(struct file *file,
                                           size_t size, loff_t *pos)
 {
        struct shrinker *shrinker = file->private_data;
-       unsigned long nr_to_scan = 0, ino;
+       unsigned long nr_to_scan = 0, ino, read_len;
        struct shrink_control sc = {
                .gfp_mask = GFP_KERNEL,
        };
        struct mem_cgroup *memcg = NULL;
        int nid;
        char kbuf[72];
-       int read_len = size < (sizeof(kbuf) - 1) ? size : (sizeof(kbuf) - 1);
        ssize_t ret;
 
+       read_len = size < (sizeof(kbuf) - 1) ? size : (sizeof(kbuf) - 1);
        if (copy_from_user(kbuf, buf, read_len))
                return -EFAULT;
        kbuf[read_len] = '\0';
 
-       if (sscanf(kbuf, "%lu %d %lu", &ino, &nid, &nr_to_scan) < 2)
+       if (sscanf(kbuf, "%lu %d %lu", &ino, &nid, &nr_to_scan) != 2)
                return -EINVAL;
 
        if (nid < 0 || nid >= nr_node_ids)