Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4642791iob; Sun, 8 May 2022 20:20:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJLnB5rjtO5FT4ukrr4ZXzTWFQoRFl6rkkZ2f6RNzZwV2bC/uVrE/J39zW9H+hkWn87v8x X-Received: by 2002:a63:570f:0:b0:3c1:eb3f:9db0 with SMTP id l15-20020a63570f000000b003c1eb3f9db0mr11621579pgb.467.1652066429989; Sun, 08 May 2022 20:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652066429; cv=none; d=google.com; s=arc-20160816; b=kSMvNUABps9h1U1BI1sSJCUp73/b4VN/DW1L7L/XmTzLVxfH80sTJE+OOQaA9pfZ3n Ud+V3F0/irDM66VVF5vWH2tqb3sDl2gRGlXNRYHTU1dtIXrtF/wT4NKcbX71i3xlQ/DS IP7y1W0D+Q0o/mgb+k4ZH+X5PcioIDCrBonoHWELrA/aL9o8yBopUjCniFRpcj7zwmDX L6al143fLbqkAlA8x1D9oUjd/85Ky5WdikArwEUjfwaL9kiJkn+Srqs0vCLzk4Afm8zf iID/SC1NtpYcBKiUfEij7moXJkmb4Z2d6Y5xWSbWsgFvZ13qGB10mqDTYaTVkRUOTTCV OFsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=41Uma7d/lsP3xWQWON3zs2lM1iFrEwZBoddB2x0AtvY=; b=X/stiwBtiMpc7Uy9IpHbvA3TA2PbyYJV5l9MXSKsIRnYJaTABP4STbAxmOZWZ/3P3J YetRjs7CxKxdEHpwal8pmSOk1mAIy2r6aMvUZjNwwvPeC8NwlUp+dKqqK3FnZshIYUaz plBXpI7q/IdzLkLFuGvfxXNLYSJaaOyMvqvjy2StdZuPhSLfM++b8bSVKCWhqMLS3O24 MOf5Z77EUUa0zrr9PEnXVsRp32P7kFLWc1KKbEr3oonCVD+cQXqWJx82SuahLTKUACDA bhPSJrws/veL4zg8D+GFB3Urp85NQr6vnRM9HXG4aRkkZ+2gwoHYiswYrtqzqJXYuqQZ ZvRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BzVTl2Lu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d6-20020a170902cec600b0015eb29579dbsi10868417plg.187.2022.05.08.20.20.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:20:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BzVTl2Lu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 40C5299692; Sun, 8 May 2022 20:20:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389037AbiEFE5J (ORCPT + 99 others); Fri, 6 May 2022 00:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbiEFE5G (ORCPT ); Fri, 6 May 2022 00:57:06 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42BF359B86; Thu, 5 May 2022 21:53:23 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id gj17-20020a17090b109100b001d8b390f77bso9859528pjb.1; Thu, 05 May 2022 21:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=41Uma7d/lsP3xWQWON3zs2lM1iFrEwZBoddB2x0AtvY=; b=BzVTl2LuhCPXAqqoulaqr9MzM70I/beRIqODBjPIFD/qx3Qb7jCfDg5/E3NEr/8ZQi /RBEAx3lwKDca3OJZvqhc7AEyvFHg0pjbCGeyu+fE9pf6w5vIdKntZaIZ7DX+WV+Dptr HpIi4jtkMOclerDN2pGbe/ih5+SWdIwQRqfVGt1Ym0bxJhS/3GnBEzgDpoRmZ0FVPvzP G6Ovf1dMWM2BVBtc962h/p9b64Ag1FTwv9e935kU3pfi5+KlSnLOoXATuA7wWNtTPAdk 0WpYnYvMJ0iYpdTDQdgL8FsECqlx+3f2jpLTyfdKxxP3jx6IvoCbQTzkRwJv3SVvZed+ JOiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=41Uma7d/lsP3xWQWON3zs2lM1iFrEwZBoddB2x0AtvY=; b=sn/GnpBhVptZhrvVGIWJPeFkDNgQaWt1yBfydOn7T6ytOYHWez4TjMXhmilte/OOzz R1ItPDsFhxg6H+bTT4YF9CjdYHHMYOm+DgaXJuniyvcKTAy8Uy9RBKsJpdhW6iIXOH4B 0WKl66QKZ/SPCxly7JQBEcEFU/7U5UwFdT2v/aVGpol4q57rePMeu/LYpHQUK/Moqf/F xYF+zFqgM7Af7X1uyMprO4oKIQjur9quEJIFtaYPH6PgDj0Bkya8usclaUb1FlLPlPOX mpb8TAjpj9hD0NBzZy70w0s1W+9465qmjrb8cZ4obyFHjncr3hgbU7bmIpypKMbRx/XV UbpA== X-Gm-Message-State: AOAM533I8QPnNqw9EmN44Ldj+8Tl1bX6YGl7bELQVPla7OnBBV19+2JL OT7eRB7RHtt1kJqNIuVVTt2agiIxluQ6Nskw X-Received: by 2002:a17:90b:4ac1:b0:1dc:20c4:6363 with SMTP id mh1-20020a17090b4ac100b001dc20c46363mr10218435pjb.79.1651812802680; Thu, 05 May 2022 21:53:22 -0700 (PDT) Received: from localhost ([118.33.58.98]) by smtp.gmail.com with ESMTPSA id p1-20020a170902b08100b0015e8d4eb1e1sm562212plr.43.2022.05.05.21.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 21:53:22 -0700 (PDT) Date: Fri, 6 May 2022 13:53:19 +0900 From: Paran Lee To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin Cc: linux-kernel@vger.kernel.org, linux-mm@vger.kernel.org, Oliver Glitta , Austin Kim Subject: [PATCH] slub: kunit catch kmem_cache_alloc failed Message-ID: <20220506045319.GA28237@DESKTOP-NK4TH6S.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Catch kmem_cache_alloc failed on slub kunit test. Signed-off-by: Paran Lee --- lib/slub_kunit.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index 8662dc6cb509..7b80241dd498 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -32,6 +32,11 @@ static void test_next_pointer(struct kunit *test) struct kmem_cache *s = kmem_cache_create("TestSlub_next_ptr_free", 64, 0, SLAB_POISON, NULL); u8 *p = kmem_cache_alloc(s, GFP_KERNEL); + if (!p) { + kunit_err(test, "Allocation failed: %s\n", __func__); + kmem_cache_destroy(s); + return; + } unsigned long tmp; unsigned long *ptr_addr; @@ -77,6 +82,11 @@ static void test_first_word(struct kunit *test) struct kmem_cache *s = kmem_cache_create("TestSlub_1th_word_free", 64, 0, SLAB_POISON, NULL); u8 *p = kmem_cache_alloc(s, GFP_KERNEL); + if (!p) { + kunit_err(test, "Allocation failed: %s\n", __func__); + kmem_cache_destroy(s); + return; + } kmem_cache_free(s, p); *p = 0x78; @@ -92,6 +102,11 @@ static void test_clobber_50th_byte(struct kunit *test) struct kmem_cache *s = kmem_cache_create("TestSlub_50th_word_free", 64, 0, SLAB_POISON, NULL); u8 *p = kmem_cache_alloc(s, GFP_KERNEL); + if (!p) { + kunit_err(test, "Allocation failed: %s\n", __func__); + kmem_cache_destroy(s); + return; + } kmem_cache_free(s, p); p[50] = 0x9a; @@ -108,6 +123,11 @@ static void test_clobber_redzone_free(struct kunit *test) struct kmem_cache *s = kmem_cache_create("TestSlub_RZ_free", 64, 0, SLAB_RED_ZONE, NULL); u8 *p = kmem_cache_alloc(s, GFP_KERNEL); + if (!p) { + kunit_err(test, "Allocation failed: %s\n", __func__); + kmem_cache_destroy(s); + return; + } kasan_disable_current(); kmem_cache_free(s, p); -- 2.25.1