Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp804479pxv; Wed, 14 Jul 2021 16:19:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5N3TiZJRgfJ4JU8IF1mQeCW626FpxbiWsc8n6z9PTyD9fsXnvM2X1ksV9nmGj1hz6s2Gk X-Received: by 2002:a02:ad08:: with SMTP id s8mr592082jan.40.1626304766339; Wed, 14 Jul 2021 16:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626304766; cv=none; d=google.com; s=arc-20160816; b=ibZRXFS0+NlrjAoyRnetnQrHHrOYgMbl+ik6wb9U3iYTPv4KXikbOwyXWk1gCK1+zT Bq88OJEsT/CeEmz/nLOj6nhsXcPwi+jzs89HRRMWyE5H0MQrLdqa42/zf6glY//75Er4 s3RGr40vrIseZ3PDn+LHNMKx+6JUNCOxTS+xdYlHOLhJKaUrtaq5GdYTzS67yCYC8Avn becBDW+hFHXJR9IyOkGfspDLFGKi2yFx4oVQr/jJedgluOxj00PF+uMVmoVhGCUDn24e ZcbKqSE82jPZmH3W/q9wu/MopnC9aTieiMfotvLsZ+NyjgI/n+y6YPkT+wKhQrViFkMo 5stg== 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=xSXZsc9S1OE/57FZdD9wfjk5cX6z161zcXWV7Ia5wrw=; b=e8xIPhyL8MexMTR8xpgH3dQBVd1vkMnVFT3OCjfRwLmdqezdYh5/hvZE5IvauosDY8 mUCmvmbFP2MHEuORL+mdJrz+Qi79c+bFA5ybzvXmcmKYcMp2UxXQ+85LjoQuulfYD9xz ZUuliSKBJdzQkshpZUmIYr0QVaBcdQRYNwkJiRU1DJoqiONlmF5YO/TXYoWPoZ+kqrct 94WV6wpCGZJUYD0SsbbONvbsJt72qKHeIZtUrNDI0/Or5O2lps72rkTzPV7nvHcQqA3J ALqswLF8Ssh1SGuwhquSB8fT9iVTeXqCsj/Kx9x6Pg/AlygCiH/MeO5cYDp/F94RBh4A 9c4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LB+yhlbb; 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 z7si4368101jap.105.2021.07.14.16.19.08; Wed, 14 Jul 2021 16:19:26 -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=LB+yhlbb; 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 S230496AbhGNVyY (ORCPT + 99 others); Wed, 14 Jul 2021 17:54:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229782AbhGNVyY (ORCPT ); Wed, 14 Jul 2021 17:54:24 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDF7C06175F; Wed, 14 Jul 2021 14:51:32 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id h1so2134813plf.6; Wed, 14 Jul 2021 14:51:32 -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=xSXZsc9S1OE/57FZdD9wfjk5cX6z161zcXWV7Ia5wrw=; b=LB+yhlbbgc0eFOjSGF+B2qd/ql4FjkJ0tFzC3VFAdIl2+Hp31+VRl/MsPWq7msTIo8 V0bV3GZY2nMR/MOZJQLRZzyOQ1RvrEOwdxemzGyqVdb6w9Oq349lZHwTs8MvjrSRZ7IR yiYC6lcqYVxZzLCwJITKDhs2Tq7rPQjBfXDHOe9rTwWd5vzMZwhoSr2ZSiQZ1vm0eqos bIYqgGK+O+pyQFDqDJiGYK4KXJ7sE8/fSrZqfDN9C5PPT2Eag2yrWJTZc34/6R4wazNm S4slxCQkdKkcCYUl2zT4KxfVMp+lTyNYZpeL/1Gr8CFZwb2ucFT0+rdPRWMyUPnTUz6e f0wA== 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=xSXZsc9S1OE/57FZdD9wfjk5cX6z161zcXWV7Ia5wrw=; b=YCRD2B6uF1lpGx+1FpimnTUi2bfnNqpabmfWAPb7juA8dHJMN2JZsAUW0miAiIV3IW I2WUyXuaIO2Ynzu77eUQaQLXBqokx2jKu34n6fSLNxpqyqd8mn6OLu64SdgdeNgOekHu lTHUAdotzM9EUwtWwqBMMv0WszZHm5mOgiyIituGw0iq/9JmmCMC9EtRh4p/A6SU2+9h Rq4xv+vRwZDeAv623ozkvVHweUXogP34Nm3wVvjaTL1aLnKAGlTN3qvnAtcHvn7NBhx6 SdLiCkJLsMFpV4tNB85mTLU/d9WJFmvy4kLyRoqANXsbA3nPh5zJJoe+quttsD6Hq8b6 GPNA== X-Gm-Message-State: AOAM533t2pAQDEgDLRVfdOKge/n8tchrS8Qn+Ydm75SduxGQUXMOAJwp qRzzQiUSZyHczIEt1zp2/s4= X-Received: by 2002:a17:90a:4481:: with SMTP id t1mr13622pjg.232.1626299491614; Wed, 14 Jul 2021 14:51:31 -0700 (PDT) Received: from raspberrypi ([210.183.35.240]) by smtp.gmail.com with ESMTPSA id 10sm3679597pjc.41.2021.07.14.14.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 14:51:31 -0700 (PDT) Date: Wed, 14 Jul 2021 22:51:26 +0100 From: Austin Kim To: jmorris@namei.org, serge@hallyn.com 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 v2] LSM: add NULL check for kcalloc() Message-ID: <20210714215126.GA818@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