]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm/damon: don't use strnlen() with known-bogus source length
authorAdam Borowski <kilobyte@angband.pl>
Fri, 24 Sep 2021 22:43:26 +0000 (15:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Sep 2021 23:13:34 +0000 (16:13 -0700)
gcc knows the true length too, and rightfully complains.

Link: https://lkml.kernel.org/r/20210912204447.10427-1-kilobyte@angband.pl
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Cc: SeongJae Park <sj38.park@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/damon/dbgfs-test.h

index 930e83bceef03767f9a2556f7ca6501a76c4cf6e..4eddcfa73996f24672344652cbb087e1a50bc58a 100644 (file)
@@ -20,27 +20,27 @@ static void damon_dbgfs_test_str_to_target_ids(struct kunit *test)
        ssize_t nr_integers = 0, i;
 
        question = "123";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)1, nr_integers);
        KUNIT_EXPECT_EQ(test, 123ul, answers[0]);
        kfree(answers);
 
        question = "123abc";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)1, nr_integers);
        KUNIT_EXPECT_EQ(test, 123ul, answers[0]);
        kfree(answers);
 
        question = "a123";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers);
        kfree(answers);
 
        question = "12 35";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)2, nr_integers);
        for (i = 0; i < nr_integers; i++)
@@ -48,7 +48,7 @@ static void damon_dbgfs_test_str_to_target_ids(struct kunit *test)
        kfree(answers);
 
        question = "12 35 46";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)3, nr_integers);
        for (i = 0; i < nr_integers; i++)
@@ -56,7 +56,7 @@ static void damon_dbgfs_test_str_to_target_ids(struct kunit *test)
        kfree(answers);
 
        question = "12 35 abc 46";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)2, nr_integers);
        for (i = 0; i < 2; i++)
@@ -64,13 +64,13 @@ static void damon_dbgfs_test_str_to_target_ids(struct kunit *test)
        kfree(answers);
 
        question = "";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers);
        kfree(answers);
 
        question = "\n";
-       answers = str_to_target_ids(question, strnlen(question, 128),
+       answers = str_to_target_ids(question, strlen(question),
                        &nr_integers);
        KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers);
        kfree(answers);