From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BA15C433EF for ; Tue, 14 Jun 2022 08:40:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8637B8D0232; Tue, 14 Jun 2022 04:40:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 811168D0229; Tue, 14 Jun 2022 04:40:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 700618D0232; Tue, 14 Jun 2022 04:40:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 605F68D0229 for ; Tue, 14 Jun 2022 04:40:50 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2CE343563B for ; Tue, 14 Jun 2022 08:40:50 +0000 (UTC) X-FDA: 79576195860.20.A515769 Received: from mail.nfschina.com (unknown [124.16.136.209]) by imf02.hostedemail.com (Postfix) with ESMTP id 55124800A2 for ; Tue, 14 Jun 2022 08:40:47 +0000 (UTC) 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> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655196048; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=to4wYD54JKpnOBBskhyBXHNr3dpSMRyzjuotjWmt2bQ=; b=0/qplMUba0IemWKKWskaQIkDaOE/yP+ig9FH6Ew3tmJwUIARf/qAuqtHXuXEjxf6qOaBvw rKLhLcnPmis03j4sbG9UqCgTDIC4T46Rjmcj+VPRO+Mt9iOZGFess7+9geuqMe5/Md5Srd GvKV+AFkbsOVZkn07fFZsWy0dLHaMAI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=none; spf=none (imf02.hostedemail.com: domain of renyu@nfschina.com has no SPF policy when checking 124.16.136.209) smtp.mailfrom=renyu@nfschina.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655196048; a=rsa-sha256; cv=none; b=P5GwBpS6EuTa0ryJpaiNJb7SvWWHAl83XiGyD/O9UGbaf6Q+Qt4HN0snK8p1oRAY/yhcIF o3DVeb3rDfreakPizsi6e8JGZYJboBnoAS3GurX/d2+rWEblJPGQYjD4kkQMjpewBjji0q dizXbK4tSMgBPx4fDRh8RvjuwGkksyQ= X-Rspamd-Queue-Id: 55124800A2 X-Rspam-User: X-Stat-Signature: pthqbo9asifa3mca9mjzp77yeaekst93 Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=none; spf=none (imf02.hostedemail.com: domain of renyu@nfschina.com has no SPF policy when checking 124.16.136.209) smtp.mailfrom=renyu@nfschina.com X-Rspamd-Server: rspam04 X-HE-Tag: 1655196047-131020 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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