Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755147AbdL1UdL (ORCPT ); Thu, 28 Dec 2017 15:33:11 -0500 Received: from mout.web.de ([212.227.17.12]:65212 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751296AbdL1UdK (ORCPT ); Thu, 28 Dec 2017 15:33:10 -0500 Subject: [PATCH 2/2] pcmcia/rsrc_nonstatic: Improve a size determination in three functions From: SF Markus Elfring To: linux-pcmcia@lists.infradead.org Cc: LKML , kernel-janitors@vger.kernel.org References: <19f2a908-8515-ce68-bbba-e74dd90d6ad2@users.sourceforge.net> Message-ID: <4ec19574-d66d-5138-dca9-463235e3e717@users.sourceforge.net> Date: Thu, 28 Dec 2017 21:32:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <19f2a908-8515-ce68-bbba-e74dd90d6ad2@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:mszDqkHFGTbSWZOZofb5OlbfqNlyH70rh/FcnFUdtb/Lg+UE+Rf UpWxW0SiJ5A4CHRESBIvt70jwQFqIOnuYMUQO7P0jMOKNwaGBOcef+27FnUjHl2jyvI6Mv4 S6v7gs3zc3Dxo1/m5NIw2Cx2FMFh9LX4mWmDJEnpRRMhLhGg7ajpu1yH62xnve+IA5JoROK HyZ9ZyDkwIbZuKZVrH0yA== X-UI-Out-Filterresults: notjunk:1;V01:K0:NJWErzwoNiw=:U2yatvW/ORyP8updSEdUy+ bx6llkYTHUp677WJMbKkCJHvkKHE0geTnBj6s5PuW6HNa5sjDz3ntyBUdNeIEpT3DNQpqbskg lv0LYvo2N+5zCZrSBgQQ8JDozoqiBf1IXTbfN9wKQV7t7mbGQawdfVk44mUVzJzHObrSM4Xbz Lgny5gX1VNMyIH3R3QXCpdPgLqY7j3XISnUF9cLR+1DnqL3AJaLm6OZV/ksuf9eG1UwdQ/+bD Zlu/7awY7BktRMyjfMrc0836fFZm9ARtpx6431185dNagn44Bbl0Ssqw6zZBSt5dZQqfYWewk OhB2dbogl+01lw11wyQh2RE8a1od1RbD8JnUrxa5VBiDhNJYXE0H9D+mGdkHnYfYUgULuEMZS wqQ9wMnTWjBIyFrk5UMLdvGVT6WFQffUPR7LyuvP/zoRX7sT9nQO9zEIB40xXzewLPPl2C8YU eKOcmq93u9s20KhMbxYsLxD7n25eE0nh+KAJ0K1NzQbdVrnsmi66He3WhC/RAmlyzyEs5zAxX yOBlgU+m1L8sEZLHkm5mYbeAqZ8+81I+D4lbOaIYRgJ3BLH7VW4Lrsk04MHKbRvFww5XwL2RO 8eD5V+0A7Okt99h179w/jRVDAENthCOt5PQgNhF5gJkj99ni+H86zSUPChCZUYPQ84KiDjOSl MavAwd3+s0YSmdcMfbGED6lZPn2Fujm15IICeyu8E+NP39FWsG921KtBGyQzdnY7Txxs0nyvK bt8Nj9brmYc/VAdJUm81Hmk+MgluZjND273qLc3W2IqhfozoaTTNEdPg1X40eSpdVuIArQJ6j laaEx3AckdMd3MtBCK6Vpf+lIW6YtrlbLUQoGAavF/Ln+/VfLI= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1691 Lines: 50 From: Markus Elfring Date: Thu, 28 Dec 2017 21:07:39 +0100 Replace the specification of data structures by variable references 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 --- drivers/pcmcia/rsrc_nonstatic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 91dc559e4a81..50169b00f389 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -120,7 +120,7 @@ static int add_interval(struct resource_map *map, u_long base, u_long num) if ((p->next == map) || (p->next->base > base+num-1)) break; } - q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); + q = kmalloc(sizeof(*q), GFP_KERNEL); if (!q) return -ENOMEM; @@ -157,8 +157,7 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num) q->num = base - q->base; } else { /* Split the block into two pieces */ - p = kmalloc(sizeof(struct resource_map), - GFP_KERNEL); + p = kmalloc(sizeof(*p), GFP_KERNEL); if (!p) return -ENOMEM; @@ -1014,9 +1013,8 @@ static inline int nonstatic_autoadd_resources(struct pcmcia_socket *s) static int nonstatic_init(struct pcmcia_socket *s) { - struct socket_data *data; + struct socket_data *data = kzalloc(sizeof(*data), GFP_KERNEL); - data = kzalloc(sizeof(struct socket_data), GFP_KERNEL); if (!data) return -ENOMEM; -- 2.15.1