Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1273429iog; Tue, 14 Jun 2022 02:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOiz1zww6/6W7Hfr9QZVUEKovsaD3S2V6WISytV6VbMlXjePxhmMeuyNiiKJ+BMzD4rx0a X-Received: by 2002:a17:907:3e04:b0:6f5:1132:59de with SMTP id hp4-20020a1709073e0400b006f5113259demr3556511ejc.755.1655200246430; Tue, 14 Jun 2022 02:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655200246; cv=none; d=google.com; s=arc-20160816; b=BsPfHRNaNZ4zOXEC++7kcB/gjO+EKkD1szZuEP8Fe/xP7IIJOt2NnvH43yFh5iVmqH fh3VTgGrbmE1cRyqQkT8vurJhgaWtXr3a32siZtDwQ5dCJyv2vsWoBAapKHIWGEjhEuE qGTxX1PriZY3mtyDg/0Ou8iHZ8TJX5+hoA+Is2lVpr0p9ezwJJVp1ZK7IgYXnJRPzDu8 2DqINYzDLE5rhnYcLajW8ycCJoe+4qVvHhd8m6OphmcuolD2ki1u7hPc/I9S21FWF/Qx TV1h0hB/2ru7XP2JADCxA3erVkBwFWwcp4bBHBYphaCXb0dKgh+cHFwREboQsaAXtGRp p9SQ== 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=Oik/GrJtXBX79BmEZq6a4uLxFf6dMjCvvg61OqSiQik=; b=jQR3k9IAZsWx6dWKXQ9adZoNieOx7gUeYsSOA3dBuyrVs2CtxuuUWqCtr/gR2EFFNG sBu4YQ9MG/pVN0X68mN8LFvtqcHrZxFG1ldvwb38lZ9GvBx6g6VcWLfkOq7Pp0kqnj2g 2+3d2ahmvKvssWSGRlACumr0DaqPj7qKC5kJ7uswVXA3YpyOyOyAohe3I2LOXiTned8T rtTzVAfjAtmLftGncV/i2woVWbHe1cp8LhPymU/umRtMN7TgHeAOi/H424uaocAivCIA tpfa1SJYefKKxCcn0cmx77XA/KRBcRIET5ukGv4lMqtZeyqlgG8McAohDe+Pbz/5yNIj 32FQ== 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 qa8-20020a170907868800b00715867834e3si7145594ejc.506.2022.06.14.02.50.19; Tue, 14 Jun 2022 02:50:46 -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 S1353535AbiFNJZC (ORCPT + 99 others); Tue, 14 Jun 2022 05:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356124AbiFNJYk (ORCPT ); Tue, 14 Jun 2022 05:24:40 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A6FF45AF9 for ; Tue, 14 Jun 2022 02:24:07 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 94B911E80D8F; Tue, 14 Jun 2022 17:22:46 +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 iIj6q3QRWcQD; Tue, 14 Jun 2022 17:22:43 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: renyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 185C01E80D5E; Tue, 14 Jun 2022 17:22:43 +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 v2] mm, slab: check the function kmalloc_slab return value Date: Tue, 14 Jun 2022 17:23:12 +0800 Message-Id: <20220614092312.14006-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: - change return value of error path to '-ENOMEM' - not check for zero --- mm/slab.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/slab.c b/mm/slab.c index f8cd00f4ba13..eb3fb042f4f4 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 (!cachep->freelist_cache) + return -ENOMEM; } err = setup_cpu_cache(cachep, gfp); -- 2.11.0