From patchwork Tue Jun 12 04:27:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyang Jia X-Patchwork-Id: 10459233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92E21601A0 for ; Tue, 12 Jun 2018 04:27:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76D782863D for ; Tue, 12 Jun 2018 04:27:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AE272863F; Tue, 12 Jun 2018 04:27:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 118BB2863D for ; Tue, 12 Jun 2018 04:27:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbeFLE1M (ORCPT ); Tue, 12 Jun 2018 00:27:12 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34274 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbeFLE1M (ORCPT ); Tue, 12 Jun 2018 00:27:12 -0400 Received: by mail-pf0-f195.google.com with SMTP id a63-v6so11404278pfl.1; Mon, 11 Jun 2018 21:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=SStYGhlcztqQ2MrXH1jzRquNyv/Gz5mhdhNphCnT8tg=; b=MksncrhAv+28cnPrTeqSYPjg0teTHebXSTHHFRMMHB9Oa7iemr97MRBUi71KNfp6kF abgC+HFzraaqgsPVQBHPJ+/l8w13HtcKecyoDCBpyzQYE9707epJQ/rxjIY4nHUJ+VYq L+qKCTel8jpgLgP2Bz6ct+vakZTxEhGBdu4f9/vgnBI2GZFRbX7EUE0LAE7q3f49tm3P 8cJL1LnZY8AQ6gdl5sEUxnNgp+/Uk77gCWm5v3blHbbbkHYvGvQiJrYVfrTKtkWCL4+w kwSS5PxihyX41rmx/rzpyWEZq+6obHk3rcez14CJSfjvsVsfQl1UGt66bS8Y9qnZs5BB jkMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SStYGhlcztqQ2MrXH1jzRquNyv/Gz5mhdhNphCnT8tg=; b=J7XIS1GqUVyecm/LmR7CovgYpTk4hu0BXXPcwx0lZ5c5LikYj5xTVdIp38nr6mARYH k455Cyc9PdsOuTPD9hd+MroKO9AdXCuPRQFXOk/s/243GIz7zaV8uL0xVU+MF38oKEtD mzY8UnmALtcza+LQ/cX2M0Ebud+jiitr6akZt4GekK/t+/RayTH2xPSHPtLchh9U+mps ymOS4Di7gLl3wV87tc9PhP0AV80aS1YxdcYkZmBjSENyGnyHYHnGokdYrEeyvvxCdbih Q8WGm/WYXt9DVy9xRkW8KWqCq4f4R2Ckf/HCXm3SAzKgA5awA9M8FJ6/25IMPPRhHP3B Puag== X-Gm-Message-State: APt69E0jIIzNiFEV8WGSA/YjWdweG/3jCkKMgb5U5H5Vd61f1yF2qTwh Thh+7clR2kA+VN0lSSV6N7E= X-Google-Smtp-Source: ADUXVKIXBgY4TeQGWFZM7aYt7WRtOsIXgsiRlfWxGzPBklqFWT4qf++bzaWoStIbI/a4m62CRGr3vQ== X-Received: by 2002:a63:6f42:: with SMTP id k63-v6mr1756600pgc.135.1528777631602; Mon, 11 Jun 2018 21:27:11 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id c19-v6sm4347607pfn.182.2018.06.11.21.27.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:27:11 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , James Morris , "Serge E. Hallyn" , Mimi Zohar , Matthew Garrett , Jeff Layton , Thiago Jung Bauermann , Dmitry Kasatkin , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] integrity: add error handling for kmem_cache_create Date: Tue, 12 Jun 2018 12:27:03 +0800 Message-Id: <1528777625-40502-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When kmem_cache_create fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling kmem_cache_create. Signed-off-by: Zhouyang Jia --- security/integrity/iint.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/security/integrity/iint.c b/security/integrity/iint.c index 149faa8..c074fd8 100644 --- a/security/integrity/iint.c +++ b/security/integrity/iint.c @@ -172,6 +172,9 @@ static int __init integrity_iintcache_init(void) iint_cache = kmem_cache_create("iint_cache", sizeof(struct integrity_iint_cache), 0, SLAB_PANIC, init_once); + if (!iint_cache) + return -ENOMEM; + return 0; } security_initcall(integrity_iintcache_init);