Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3398444pxv; Mon, 12 Jul 2021 16:45:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1hTfPXiTHEmwsuMTDNLKG2SxAs5N3ezIYdoa7VERhhEMjpmqB9kEpsu6XYYDN/xc0sgM6 X-Received: by 2002:a6b:b883:: with SMTP id i125mr1056765iof.104.1626133523769; Mon, 12 Jul 2021 16:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626133523; cv=none; d=google.com; s=arc-20160816; b=HuX3uGmYrNKPp8vHuHS531p9BQSw9UT+yFY5AsWzt3MKbzmSCvUD3nGRjhqoeu7CWf HDUZEGDFquRGJ6rDO1p6okYAlQTM2WIaDds6j46tuYpCE4lJDDRc2/5F51DSkoCT3ZPv 2vzPchqOgh3dKfO7VpSTf2cs+GRa5iE09zjUlYjzYMG9HRjObPkqr558rY/NraXF6CMX NU13mc9ectV1ZIw6TY/LUAMGqP7jNxQWqXmj+w8dqvdp0GZUzEnLQ2hzuhpJZdlTWaB4 I1WDkIinSM5fG3ez7PLHhnsF8BZq7XpxDtaFcB0xVhIMOlSsq2QF3EHiDy4vbmdhHDtU qh1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=ZdcC4EOvokLDp7iGvpkIzf7OidD6sSk4XoFIM4xk3AU=; b=uZtNMdJWb18V7OtDaguZo1iXIMKD8SB9Ijy8zK0GWrKpaIsYkH8wv+jNqJyD7t96gS Bye4wbcanj/wW7XVAkEpeyqcUsvitH02RgMgMj3O7+dT0mFRGV2p83GRVCIk4aztpxo2 4/nhg8X64knP4/mryyR3bC6TDz3JUgolyCuxeiChkIlf6knLkHumDp+jHEuRsqdSIA4c eWxzdBjCPuT4mosf8vEP8C/pbUhPehdAsBwJZTpzkhk2G966oGUH8wxqnYpkror0rUDJ NeDrh2decm6AbNHjt/JFrprX6nqtVK4S0VMlud+ipk0upmSNWDdoakEFpt7di5JNBNjn lcgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PhvZMt/q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m11si19600775ilj.100.2021.07.12.16.45.11; Mon, 12 Jul 2021 16:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="PhvZMt/q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbhGLXr3 (ORCPT + 99 others); Mon, 12 Jul 2021 19:47:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbhGLXr2 (ORCPT ); Mon, 12 Jul 2021 19:47:28 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC4A5C0613DD; Mon, 12 Jul 2021 16:44:39 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id v7so19977337pgl.2; Mon, 12 Jul 2021 16:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ZdcC4EOvokLDp7iGvpkIzf7OidD6sSk4XoFIM4xk3AU=; b=PhvZMt/qVfhwAJzYDBf6zlD0kGcx/nd81RJHYJm8GR1+RxH/GMwlQBDZuaIG37cQUn M9Du3K4PI829rOOvPbmaY8o1mUcsdT4ePldlyE0qI5RtHxDfxdmF/p2m6zCbsQKnYlSK sf0nj5mkoZLjPNjNy+LJ9BfGu56Z2Bm3Wmse3xhi7yqBENtoHeLbGTg49lmATzc9RXAL W7LaXVl/Owf3HHz7hfHfXAw1V1jr7cnlLAf3JqLw8FlNcgtNSnFrkNqKEjmFVpFQYwlD 66nDUSPhgqnoXkT5iZmSuuMscOfy76QhVLeVyC3s0uo78rxb4AQ5Pgr+JnuQFUpvSHRQ DrYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ZdcC4EOvokLDp7iGvpkIzf7OidD6sSk4XoFIM4xk3AU=; b=op6I0sOqp5gAAb0cn3oAiJyZa4R8PWfqaqSoqAJjqq0D5l82KJrwkP2P6xrv0VS9Pc QGuxOeygZhY5aG5VMLQ86frO+U6/1GXtIq5XZ5N10M80ZzreNZWmIG+UXdt7cvXLCqls 6v3xEypz5ELjRkC95MX3zXGPtvHVnTzLG6IfdPJ70cifhYh4/OO5FDnAnMODVIepYFc4 UIp1Y7SYBFqxhmEROcm7YCZkE0waavKBm0VABz3IH7eA8jSOyKgAtkhQh2uyqEySBKTl /KZxBtSIWU5XnIdqFeCb1oidUMpi//kyTiMlKcJqN39bNBv5PtWwbk7m3/6NKkgjr49j /zLg== X-Gm-Message-State: AOAM531+p4iauT5P84xWl61UlHUtr/ZByADjVjedLzLz8Wh7LjGWY+RD egHIx0V3qehX7L3NloC670k= X-Received: by 2002:a63:b60c:: with SMTP id j12mr1501604pgf.393.1626133479231; Mon, 12 Jul 2021 16:44:39 -0700 (PDT) Received: from raspberrypi ([210.183.35.240]) by smtp.gmail.com with ESMTPSA id u8sm473837pjf.20.2021.07.12.16.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 16:44:38 -0700 (PDT) Date: Tue, 13 Jul 2021 00:44:34 +0100 From: Austin Kim To: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, austin.kim@lge.com, kernel-team@lge.com, austindh.kim@gmail.com Subject: [PATCH] LSM: add NULL check for kcalloc() Message-ID: <20210712234434.GA29205@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Austin Kim kcalloc() may return NULL when memory allocation fails. So it is necessary to add NULL check after the call to kcalloc() is made. Signed-off-by: Austin Kim --- security/security.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/security/security.c b/security/security.c index 09533cbb7221..f885c9e9bc35 100644 --- a/security/security.c +++ b/security/security.c @@ -321,6 +321,8 @@ static void __init ordered_lsm_init(void) ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms), GFP_KERNEL); + if (ordered_lsms) + return; if (chosen_lsm_order) { if (chosen_major_lsm) { -- 2.20.1