From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752638AbdKHUid (ORCPT ); Wed, 8 Nov 2017 15:38:33 -0500 Received: from mout.web.de ([212.227.17.11]:59053 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbdKHUib (ORCPT ); Wed, 8 Nov 2017 15:38:31 -0500 Subject: [PATCH 2/2] net/sched/cls_tcindex: Improve a size determination in two functions From: SF Markus Elfring To: netdev@vger.kernel.org, Cong Wang , "David S. Miller" , Jamal Hadi Salim , Jiri Pirko Cc: LKML , kernel-janitors@vger.kernel.org References: <7192a5ea-b712-6bec-5d9d-01906218d404@users.sourceforge.net> Message-ID: Date: Wed, 8 Nov 2017 21:38:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <7192a5ea-b712-6bec-5d9d-01906218d404@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:qekrsURRcUzdV6zjoda6QT124RNVLrIgvBbFcSe/fNq8erC0KQf wXs5KpucJefTkkdQXECPpmRPcyDG1rvrPYwuH38CGUk7Z4wILhxL9YZWiiKBxFDNKF7riyz 7ge4hlkxGVOOY8ec0QsVRnLCs2ap03EXtC5TqwUwndaI7FNtUtDqvYP1vphl1QmWgfjZnao 5NccWclAv3X22XavSbacQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:cWwsoyM0n7k=:R+NCQWpGxmioaGoXkdbGiD TmEhlbTRDD6KVJsZ+tMfOEdjVYbjrqNkkpccoyhnd8uGwo1PF0nGIosYKLU02Lx3r1kiM8SFN 88/ib6numP7UMchwoyxwbqnzVYQkkchCTqcQrZ3p+DsW9aIF+1VCr51MklEHZoeTQK3IFCtDp pI5wJX8FNP+ZE5hlVb8w7lC9zgNbpO31/Mk+BDdYxVw+E1i17U3T2MpuT2DqaD630gCTcTifj ju9oQuCclCKLIcbcwOp/gIZ9RJkZZqrQ1gs4K6nXjJ37IDAJJdDiNvLzqmwT7WbWjIeEQ/Lh5 e+x+BMcYV6+tlrikR99F/5zjTsfqlVx1fR7ZSEhp8deTO+bSro5oe+FUd41uLfeMw/5MfUKc0 TM6bXTbmOvMGTTEwe5y+cIdzQZd/2q1lCaCxnkVyD9Uqu4XMHxlYPGALP790gCs2LTxX1sC5v HHr/Z886clNNi0n/eKHZZMOd7x4sZsFBbLm8gfRpLKCmQCri+EN/CbL6Kj1UWfjUG2D7JPY6L 3eQImYhXXeju0xOata+k1ovEGvvd2KXeaLHWv8czWT44AFYuRt4oo+kBvJ9uDyjYCg4C0aDsK uHVzZfpVAnjgE3WVWEWigjbfJr4TLi2TRLZnr9Kn8UFwkBr3RE3KiHeoA6cjzMfRTmpdAHuNo JEU7vQpPOWv9pA/jpbcNNxfKjB1rlixZzSxvcfhUuzq6MLBV31jBxgFsxl5UNfBoADVUl9ECb 8FLqNbL7IVR2Wb5oPMGnFdDJLjjHIYPT9YbKAJLlI6k+jC9m6Eq3yeWh/zV+sl0DnquRp7DkA TQSUvWOtyhkfCECp8t06vuA4GgaEZ8JzROJH//pRSi0wG83SoU= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Wed, 8 Nov 2017 21:17:26 +0100 Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- net/sched/cls_tcindex.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c index 24f05bc09084..0f1909c6545d 100644 --- a/net/sched/cls_tcindex.c +++ b/net/sched/cls_tcindex.c @@ -130,7 +130,7 @@ static int tcindex_init(struct tcf_proto *tp) struct tcindex_data *p; pr_debug("tcindex_init(tp %p)\n", tp); - p = kzalloc(sizeof(struct tcindex_data), GFP_KERNEL); + p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) return -ENOMEM; @@ -413,10 +413,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, } else { struct tcindex_filter __rcu **hash; - hash = kcalloc(cp->hash, - sizeof(struct tcindex_filter *), - GFP_KERNEL); - + hash = kcalloc(cp->hash, sizeof(*hash), GFP_KERNEL); if (!hash) goto errout_alloc; -- 2.15.0