Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1255074iog; Tue, 14 Jun 2022 02:24:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3Ng3W2ZxYqyIZ/eBxLYYV7EFCs6fc1cOXZjMzKwWwL+o9fBVPxC3/xUVBwJBjLtrh55Y6 X-Received: by 2002:a17:902:7483:b0:167:cfa7:ff3d with SMTP id h3-20020a170902748300b00167cfa7ff3dmr3526168pll.61.1655198693424; Tue, 14 Jun 2022 02:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655198693; cv=none; d=google.com; s=arc-20160816; b=blUh1H+BZeyx+KjzTJj30QISAuDPx0DsnoVC3XqDBJzl3aO+ev7B1Q4qtyPerFqpCN s0S62iDQJ6mkA0OMkqx/FvTboc2xN63FpJ/mIgEVo4znWq6SlFB26s4VwjU1X2ZGFf/j ki1WjSjrMaYxr6+QTM5Tc5EJ19r8Xw/6fDTI8/s04EUqcI6/NzMszenG23w7lS++BPKM M9HY5VUwJFAz7Ld2BkP9VAQARJ6ma1+G+zXQj1M77JA9QMfr2w3jiJVY2czCZ3p0cz0w JSUpxkiykH/l/keAiiC3GVTS8sBkq1anrrRlVrzhFFAUgLqFt55N+4ojToK7zwAl2/6C +Ruw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=to4wYD54JKpnOBBskhyBXHNr3dpSMRyzjuotjWmt2bQ=; b=qzkga2TMyn1MWHNnGbtvdkf4nLbsqfB0/vmDLJzbswjSUOJjv/YjJJlyoRW/GFTlZn mGoGrhCT6SfeIKEvf5fD60B/UkBzbfxjZvjBMcfyPt/96jpL2EuqAy9Od5ChClThaVDV NhTFqeGJfwK6NqboQ6gBqJqoVFejXB298vLMWUEBEWBwZxSFbC/+dUzF98cKkRr18x/4 R15AeOBar1eJW3NCrKOY4FatbSVSNK/7zPrAJfP9UQus1IKzTGTufXWdjbhXOEioAbcZ x5DAWygmubSHQ0HByxaf/GtCCPhpjEoW877OfvffF8PEQdv49etnwm7OFCDdedh2dyEn erFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a636116000000b00408b1d60fe3si433054pgb.320.2022.06.14.02.24.41; Tue, 14 Jun 2022 02:24:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355789AbiFNIlc (ORCPT + 99 others); Tue, 14 Jun 2022 04:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354798AbiFNIlB (ORCPT ); Tue, 14 Jun 2022 04:41:01 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E7266427D1 for ; Tue, 14 Jun 2022 01:40:44 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id BCB5E1E80D5E; Tue, 14 Jun 2022 16:39:24 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UNy4Lc865SsX; Tue, 14 Jun 2022 16:39:22 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: renyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 2B55B1E80D0E; Tue, 14 Jun 2022 16:39:21 +0800 (CST) From: Ren Yu To: cl@linux.com Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, liqiong@nfschina.com, qixu@nfschina.com, hukun@nfschina.com, yuzhe@nfschina.com, Ren Yu Subject: [PATCH] mm: check the function kmalloc_slab return value Date: Tue, 14 Jun 2022 16:39:39 +0800 Message-Id: <20220614083939.13508-1-renyu@nfschina.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220613102438.27723-1-renyu@nfschina.com> References: <20220613102438.27723-1-renyu@nfschina.com> X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_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 As the possible failure of the kmalloc_slab, it should be better to check it. Signed-off-by: Ren Yu Reported-by: kernel test robot --- v2: - fix build waring integer from pointer without a cast --- --- mm/slab.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/slab.c b/mm/slab.c index f8cd00f4ba13..72135e555827 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2064,6 +2064,8 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags) if (OFF_SLAB(cachep)) { cachep->freelist_cache = kmalloc_slab(cachep->freelist_size, 0u); + if (unlikely(ZERO_OR_NULL_PTR(cachep->freelist_cache))) + return cachep->freelist_cache; } err = setup_cpu_cache(cachep, gfp); -- 2.11.0