From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759990AbcHYQZE (ORCPT ); Thu, 25 Aug 2016 12:25:04 -0400 Received: from mout.web.de ([212.227.15.14]:51507 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759892AbcHYQZA (ORCPT ); Thu, 25 Aug 2016 12:25:00 -0400 To: linux-arm-kernel@lists.infradead.org, Russell King Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall , Paolo Bonzini 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.9.3