From patchwork Sun Jan 15 15:01:11 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: 9517443 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 C70D260571 for ; Sun, 15 Jan 2017 15:01:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB16E28420 for ; Sun, 15 Jan 2017 15:01:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE5A42842D; Sun, 15 Jan 2017 15:01:32 +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 591E528420 for ; Sun, 15 Jan 2017 15:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751099AbdAOPBb (ORCPT ); Sun, 15 Jan 2017 10:01:31 -0500 Received: from mout.web.de ([212.227.15.4]:56162 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdAOPBa (ORCPT ); Sun, 15 Jan 2017 10:01:30 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MLgCx-1cRx5l228R-000qhM; Sun, 15 Jan 2017 16:01:14 +0100 Subject: [PATCH 04/46] selinux: Use kmalloc_array() in hashtab_create() 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: <66451d7e-f9ff-1d53-e919-d237a24ca8a2@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:01:11 +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:amib81OMTNeU3goW4dfIKZs6Wsq9n4/d6Mmw3ZJ1YQ/08A4ZwiZ E0QV8ktCdXJx8J4pAhXRtPPNevZw8HzmPsW3EMYcD36RK2Mn9VrHfhlkeYAq6kXvFn4TDtY s33/Y6fMbKzRLBkCnCBtgat3QifTUqLDSBqQmn77+OAtiO/ViEcUJ8NMaluwAlslLG85mxp /WCWZHksXHpS1qxjU7Gow== X-UI-Out-Filterresults: notjunk:1; V01:K0:HG4X66nuufE=:AF4c2B/YJoTQeus6yrMNMO EWe3FJRTp8zpwc8e3TD0skcwiamfTnDI3kEi/MeHW5GXhnoNR6FkgZIDJGQCcFnZFAmyL41oo rQgTO7fqgyAAsIK5OvVXM02+6Q5uokyQAsst00Ng9XCGcDSdqIU4EdVDk4bQtoX7Ks8pnp+8P CaCeTkvnvuJoofxw1LDd3WaR/4vITTDAP7lf04OU3FY+pDpUiy2852xNIQNtjqoZXkkuMUvvE ea+esfNGlg2OIYun5g0JamccLFQUZRd+2Jrj03SD1fk6iE3aUHpkxu6+/aYAm7b3jC2hiiOVh UPKfowk5dIZ5UVCeoj4y4tB1eCp5+9yYzEpuqklN+n5NW1hFXZa/RTpIjLlM7lm53Yj2upDKw UMexAnHEYeJ45+2/kXzqtPqEsozpivbWC8gpj8dMgGz5suchVDmTxHcYX/EIMhGvxZtzrGlvS 07G0kcgiJ0ol10NtCXOAbdtZka6B/TyStKOnCBMC5E92eDO70Uo+7I9Rx/QAqZoji22VkPyMc lG7CCb5lImawpOLSq6+/eCaO9RU1nUte8AK213mdJQnphQBokdiMFH7QjMe61AcBloHwd5SBV JIzhSW3naRrsv4ASfd7I1yy8lK/WywIfjK/kw2z0/6IFz2I/zdRZVfdGG75k2OeYpGXWdVv8e BBOhMvKUq+pNaR7grZTtYm+Ml0H/unIkecToOkW+qqAqowSEYLR2d8Lh1wX18M268djHYZnMx 1gotOSUcmYx0/2QxKOnfV9qyUP6lx400d2F2JJIWeb6NtQhMBdwHQ/T74Z0jsgLBx2zCvwrRi rWXemh4 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 14 Jan 2017 12:06:13 +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/hashtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/selinux/ss/hashtab.c b/security/selinux/ss/hashtab.c index 2cc496149842..dc99fff64ecb 100644 --- a/security/selinux/ss/hashtab.c +++ b/security/selinux/ss/hashtab.c @@ -24,7 +24,7 @@ struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void * p->nel = 0; p->hash_value = hash_value; p->keycmp = keycmp; - p->htable = kmalloc(sizeof(*(p->htable)) * size, GFP_KERNEL); + p->htable = kmalloc_array(size, sizeof(*p->htable), GFP_KERNEL); if (p->htable == NULL) { kfree(p); return NULL;