lib/test: delete five error messages for failed memory allocations
authorMarkus Elfring <elfring@users.sourceforge.net>
Fri, 17 Nov 2017 23:28:00 +0000 (15:28 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 18 Nov 2017 00:10:01 +0000 (16:10 -0800)
Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: http://lkml.kernel.org/r/410a4c5a-4ee0-6fcc-969c-103d8e496b78@users.sourceforge.net
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/test_kasan.c
lib/test_kmod.c
lib/test_list_sort.c

index a25c9763fce19f17c723b9db3645ae93ba47dcb6..ef1a3ac1397e88e436f0fd282804988f3d9b77a1 100644 (file)
@@ -353,10 +353,9 @@ static noinline void __init memcg_accounted_kmem_cache(void)
         */
        for (i = 0; i < 5; i++) {
                p = kmem_cache_alloc(cache, GFP_KERNEL);
-               if (!p) {
-                       pr_err("Allocation failed\n");
+               if (!p)
                        goto free_cache;
-               }
+
                kmem_cache_free(cache, p);
                msleep(100);
        }
index fba78d25e82569e57845d16b36c271d0848099b0..337f408b4de605641ac925f502b95758f1fc4841 100644 (file)
@@ -783,10 +783,8 @@ static int kmod_config_sync_info(struct kmod_test_device *test_dev)
        free_test_dev_info(test_dev);
        test_dev->info = vzalloc(config->num_threads *
                                 sizeof(struct kmod_test_device_info));
-       if (!test_dev->info) {
-               dev_err(test_dev->dev, "Cannot alloc test_dev info\n");
+       if (!test_dev->info)
                return -ENOMEM;
-       }
 
        return 0;
 }
@@ -1089,10 +1087,8 @@ static struct kmod_test_device *alloc_test_dev_kmod(int idx)
        struct miscdevice *misc_dev;
 
        test_dev = vzalloc(sizeof(struct kmod_test_device));
-       if (!test_dev) {
-               pr_err("Cannot alloc test_dev\n");
+       if (!test_dev)
                goto err_out;
-       }
 
        mutex_init(&test_dev->config_mutex);
        mutex_init(&test_dev->trigger_mutex);
index 28e817387b04f1c8862c54deefd4e8309f26437e..5474f3f3e41d0715fec16a6db866a23c45ed231c 100644 (file)
@@ -76,17 +76,14 @@ static int __init list_sort_test(void)
        pr_debug("start testing list_sort()\n");
 
        elts = kcalloc(TEST_LIST_LEN, sizeof(*elts), GFP_KERNEL);
-       if (!elts) {
-               pr_err("error: cannot allocate memory\n");
+       if (!elts)
                return err;
-       }
 
        for (i = 0; i < TEST_LIST_LEN; i++) {
                el = kmalloc(sizeof(*el), GFP_KERNEL);
-               if (!el) {
-                       pr_err("error: cannot allocate memory\n");
+               if (!el)
                        goto exit;
-               }
+
                 /* force some equivalencies */
                el->value = prandom_u32() % (TEST_LIST_LEN / 3);
                el->serial = i;