From patchwork Sun Jan 15 15:43:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9517601 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 B21CE600C5 for ; Sun, 15 Jan 2017 15:43:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A418628387 for ; Sun, 15 Jan 2017 15:43:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98DB2283AC; Sun, 15 Jan 2017 15:43:26 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 4A32D28387 for ; Sun, 15 Jan 2017 15:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751291AbdAOPnZ (ORCPT ); Sun, 15 Jan 2017 10:43:25 -0500 Received: from mout.web.de ([212.227.15.14]:61650 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdAOPnY (ORCPT ); Sun, 15 Jan 2017 10:43:24 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lgpcs-1cpDtA1Xsc-00oDat; Sun, 15 Jan 2017 16:43:10 +0100 Subject: [PATCH 43/46] selinux: Use kmalloc_array() in sidtab_init() To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <9ce64f74-f424-b9c5-605b-a54982888e1a@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:43:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:arkslFT7oKLzW3FFcfD+kCNWT+xQxb/owYbdRgBSdvHaGTfkfEW Qo9rbYbQtvavwHjX7TdJVUfkYY74i6XffgeXL7gOsLQGk34kLYkNLpWLG/SPicjtQRWoIfs ++M+F3iBcms6PFmbqJzYYhSw2O8ibvHL3NtO3cfl4kjNemWZ+Pr6ZX4KH2Q2yUuBHWMREOl HFKByZ485mvouGFGjeghw== X-UI-Out-Filterresults: notjunk:1; V01:K0:iOzpqiuLoFM=:9RRtO2dptpm0dNpyc8VX35 d+nfh7DOEz9nRQxIx0C3xLYIIYsObXXWKLWkXGgA79UgJRMmQ+DQGNrwieJEU0z/ZHld6NvnK lAfsRAjAC77QCgtfaO850WawhwoCLS39NclRiv+3nuIJdZFoYLw5xxB3Ew5lze0A44dgEuMYK SEwMqdVTjbctPwKZoP1uBKBkrWFwHp2w8jDgUcVSLKW1HfywHwKG/vNCzCvlhQAtNjx6JxHxH RLpj2Q5VPqpAILQOH7+29ptiP+ca8Oczw3yYMuAU6yViDXMQr4nfx1fsGUacCkINOE6X2Cn+0 hdvmTTzVcsh4jtM/U47iDRYX31pynjdwJuetq9d8vhOx1E0wnAID4oOLKtsQ8O5bTTfGhR1tB bgENe3dffLZeYzyJKOldoXAbHNxrt118VnNqHM+DE8mYrML8yPx1nR7UbgwDek7CrWmCmbuYi qhd2uLfhfXQ2Z4DewhzcJ9jLGNvpf8QSd3DtPwz9FAf4HcHDhSv4L/YzcreKSwTGroSuUVDUo k1Mfq5UCicwclf4hs9OuRhPU4oyn1ergda+NDMEyT59L3fim5VEwm/K+0v/mlBBVTxWHyWYdW 7Zs1QR9SMM3o1XkIWZU5FtnayCoxhHUxxornVnNS5qYrUhch9FZAQNks0hLchrA1cdOe/PeVE 575GmYo7ng3d92BcTAC6Cp4VK5TnMS0unVRuEzTccl0bABCzyFULXNP7/Ieh3As6rJSq4pye1 XGVCypUjXgtFEZ/JQ7jFP8K5xEUrAYc55QTH/ghmo7fQzia6HS7Ej5KiCwn+WhoDr4KwoTa28 unZArKs Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 15 Jan 2017 13:13:19 +0100 A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index 5840a35155fc..c9533b21942b 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -18,7 +18,7 @@ int sidtab_init(struct sidtab *s) { int i; - s->htable = kmalloc(sizeof(*(s->htable)) * SIDTAB_SIZE, GFP_ATOMIC); + s->htable = kmalloc_array(SIDTAB_SIZE, sizeof(*s->htable), GFP_ATOMIC); if (!s->htable) return -ENOMEM; for (i = 0; i < SIDTAB_SIZE; i++)