From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751336AbdA1JeE (ORCPT ); Sat, 28 Jan 2017 04:34:04 -0500 Received: from mout.web.de ([212.227.15.4]:63955 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750921AbdA1JeB (ORCPT ); Sat, 28 Jan 2017 04:34:01 -0500 Subject: [PATCH 1/4] dcbnl: Use kmalloc_array() in dcbnl_build_peer_app() To: netdev@vger.kernel.org, "David S. Miller" , Pan Bian References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sat, 28 Jan 2017 10:33:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:9Zi5iqO0MA8pxYh1OubHzDRD1J+mY+r/VJowLZyQ515hTjG5wK/ 68h9PRd7Fy7ey47Uezh/M6Baw8HpKc4CYVUhZCFNkW20lsPWBMVRs3lsrxMQ9MwqAQkviKf uz5jELhfuuM/1/f8/brHVcjgwOWi+OpQJAPihJDE/DPaKqO3XfFkjKXGWoQzJpCF9FlI2s0 7aa9BRArHZ6/gpnt0WLJg== X-UI-Out-Filterresults: notjunk:1;V01:K0:IWRewyvmpjc=:nV9VkWhEvDYlS6CTBkiLHD QDmRNUSPImTlF74muXHtAchqsmzWO5QsU7HlvAB0S59cPRg+rxMMNocx4aDXFW9lZNN8DvSIa u+NnBFTELFJWipjUy4tKJ2Hrkz0y1Wj4Q505RUVjoCeFHptXkz6mh2N32VmEDdG8/FsocbkwN 8DK9+3L6t2M7W7PGbhp1uXLtOPYQycE60X82iw+enXIrWgYqn0xFuEMmT7GY34IC0mFIz9p7r 0fKqVzBftYF37IOm0ksO938yQWnH+gLOQzdI9XBYLdDXImW6hlYBc6JG5NZgtFBcegSsQeSFb 0VKC6+FW5CAGFALU5aTC4cNyvsV9S63Yy6ZZuo5QOlE2s2pCE1MI3D/5uS8y+QWPggIkwNH0s nDSU/YfxhQeTJR7KY6fwhPE30oJcuWKjA7xDrvnMLtXdW0sCjkPoC+4isR4CicVefS8oI/2K5 avNTWc5Uzgwxcbjp4zxBvRE5wvIIpCtHHZVZobZlQ04cqCXwFIBDtnZZTZa/pP8drteIi2V44 ECz0+p2jE67kowZpgJYnvhn+8DNpjiLvexmHJSYfe9b/Fj+7UEh2Zh6HLnen6qHGmkzsQHwBN Ds9eVrk0iMNqEgFynJ/oNtAKRqO3MgBVPE55YMzCsiHKVby65x0OKpVrIjWyMepYXwzugM+sn NxN0gkgI/FxKnKaugsRzeU1rS7wBSFeAPsSVSXcRhqqlMfdE7JvxO2BS86xE2UBN1QdIm+4wi thZ1UILiQ8AAgato76gHTjQe7F8E1U3i9QP9c/zfM7qUzmIlZGKK3h5dSDenyBha4ElswcAbI aeDzI4oL6fiQ+OxEQckQNIMor83Tw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 27 Jan 2017 22:30:09 +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. * Replace the specification of a data structure 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 --- net/dcb/dcbnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 3202d75329b5..76fd727e2eb4 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c @@ -990,7 +990,7 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, */ err = ops->peer_getappinfo(netdev, &info, &app_count); if (!err && app_count) { - table = kmalloc(sizeof(struct dcb_app) * app_count, GFP_KERNEL); + table = kmalloc_array(app_count, sizeof(*table), GFP_KERNEL); if (!table) return -ENOMEM; -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Date: Sat, 28 Jan 2017 09:33:44 +0000 Subject: [PATCH 1/4] dcbnl: Use kmalloc_array() in dcbnl_build_peer_app() Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: netdev@vger.kernel.org, "David S. Miller" , Pan Bian Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Date: Fri, 27 Jan 2017 22:30:09 +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. * Replace the specification of a data structure 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 --- net/dcb/dcbnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 3202d75329b5..76fd727e2eb4 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c @@ -990,7 +990,7 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, */ err = ops->peer_getappinfo(netdev, &info, &app_count); if (!err && app_count) { - table = kmalloc(sizeof(struct dcb_app) * app_count, GFP_KERNEL); + table = kmalloc_array(app_count, sizeof(*table), GFP_KERNEL); if (!table) return -ENOMEM; -- 2.11.0