From patchwork Thu Aug 25 16:24:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9299563 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 571A7607D8 for ; Thu, 25 Aug 2016 16:26:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 486702939A for ; Thu, 25 Aug 2016 16:26:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CF922939C; Thu, 25 Aug 2016 16:26:21 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C89232939A for ; Thu, 25 Aug 2016 16:26:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bcxSf-0004h2-RC; Thu, 25 Aug 2016 16:25:01 +0000 Received: from mout.web.de ([212.227.15.14]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bcxSa-0004a7-BJ for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2016 16:24:57 +0000 Received: from [192.168.1.3] ([78.49.16.254]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0M7Kis-1bFV530EVS-00x5l7; Thu, 25 Aug 2016 18:24:27 +0200 To: linux-arm-kernel@lists.infradead.org, Russell King From: SF Markus Elfring Subject: [PATCH] ARM: kprobes: Use kmalloc_array() in coverage_start() Message-ID: Date: Thu, 25 Aug 2016 18:24:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 X-Provags-ID: V03:K0:b9ozPQoG7wWTE79gPqNpm9eq299A9aFsbPocQhlO7s3UNFTxk32 jAb8FX539MnkO05TVYJxqVfb7TZZihZ1/cjHUv94eQ1oT5bJrd9pdd9VMVW96gAGkRA0GSy oChNhLDkbOmsI4dmqbdPhAmUwAO1f0PNGhLwniGp7/NZ+m1VlSPTXwQWVwxqNR0H2kW0o9z DDYTaAKpeafSCo9EgGKyw== X-UI-Out-Filterresults: notjunk:1; V01:K0:InQ7hW/fxoI=:gDLVt3/YUcmJ1mdVN6wZLD btllu2RgUhMO+AHjhbgudxMsNxSxa2oSeVA39e66SbSHEzPCQfQy8RbwjX68wE++8xqkXLpcV bRCaipVLYT5kW4qOkyJVKHBgMKjPachGxpKbnIsnmvSTOG3Fp+PzZ+qr24W/0dbzMoGldOxS8 RyO6GKziFEOlFp9kmcF9v4kPNnFGEjV0UIdKklG4HpIacmzFqIuU6AmeYEl6fqhIDLUFGJLNb xRVEXdBQYp7PGQFUbE9RdBn27MQjNi9OymvA1ztn68jWBwoxuyaJWIipZv//Y4sCGxSZH0Z4G SHGT0+owBEkKO7iSGdMfAPhO7/qenqv7+A1bWHnrOqq1A0BdEyXFHQiChZLDsPC/fKyxYnLzq hfjf3Auxgp49QUfalYwvaFyZ5elJz097N6Oq2chboBcQ0uebGxRoEaL4wOx5CJJU4wn4G74/h cLJT5/GTQEerEMPrMn/gQKQROlzsLoGoQ22gONUeTuFdZC9OEuaDxgQnvlEOMBRgazI5a0O3x fxsF/Qo7MDeYRGn0I4MhoMnu3+8DpCSWVcptz26FlZhPirfyFRuUMQW9/p3piWjBTv7dMDv3V WbK5z0nmc9vjl1RY21q08k93WeWkMGyDk33clXQgenqiWwjoDPfeU14MJOvbAEapzfeM0qMqx CuQbGHl1H3knfNPZSNjkGxj1QsLEVX53lM05YwgMjd+HqGvBmAzrXjp4ZSG7YWpDlzrMYeAHd B8DrXwDyGI0NQ/gDCA1W3IfqMhxdjqLQOUVAJyuGomU156YOCG79B15GNHXHtmb1dAVp9rVLV JJEKIad38ntPUAmX9S6sP54p6yZ0w== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160825_092456_779242_E324D979 X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML , Paolo Bonzini Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 25 Aug 2016 18:20:30 +0200 * 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. * Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- arch/arm/probes/kprobes/test-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/probes/kprobes/test-core.c b/arch/arm/probes/kprobes/test-core.c index 9775de2..568819a 100644 --- a/arch/arm/probes/kprobes/test-core.c +++ b/arch/arm/probes/kprobes/test-core.c @@ -822,8 +822,9 @@ static int coverage_start_fn(const struct decode_header *h, void *args) static int coverage_start(const union decode_item *table) { - coverage.base = kmalloc(MAX_COVERAGE_ENTRIES * - sizeof(struct coverage_entry), GFP_KERNEL); + coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES, + sizeof(*coverage.base), + GFP_KERNEL); coverage.num_entries = 0; coverage.nesting = 0; return table_iter(table, coverage_start_fn, &coverage);