From: Lidza Louina <lidza.louina@oracle.com>
To: Joe Perches <joe@perches.com>,
johnny.kim@atmel.com, austin.shin@atmel.com,
chris.park@atmel.com, tony.cho@atmel.com, glen.lee@atmel.com,
leo.kim@atmel.com, gregkh@linuxfoundation.org,
linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org
Subject: Re: [PATCH] staging/wilc1000: fixes kzalloc call
Date: Fri, 27 May 2016 14:24:38 -0400 [thread overview]
Message-ID: <574890E6.4000600@oracle.com> (raw)
In-Reply-To: <1464372460.3938.13.camel@perches.com>
On 05/27/2016 02:07 PM, Joe Perches wrote:
> On Fri, 2016-05-27 at 13:51 -0400, Lidza Louina wrote:
>> The wl pointer was initialized as a pointer to a struct wilc and
>> assigned to a piece of memory the size of the pointer. It should be the
>> size of struct wilc.
> This isn't necessary.
>
> The code in question is:
>
> struct wilc *wl;
>
> sema_init(&close_exit_sync, 0);
>
> wl = kzalloc(sizeof(*wl), GFP_KERNEL);
> if (!wl)
> return -ENOMEM;
>
> *wilc = wl;
>
> so this isn't any real change and the generally desired form for
> allocations from CodingStyle (Chapter 14: Allocating Memory) is:
>
> The preferred form for passing a size of a struct is the following: p = kmalloc(sizeof(*p), ...);
Ahh, okay. I see that in the documentation. Thanks.
Lidza
>
>> diff --git a/drivers/staging/wilc1000/linux_wlan.c
> []
>> @@ -1260,7 +1260,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
>>
>> sema_init(&close_exit_sync, 0);
>>
>> - wl = kzalloc(sizeof(*wl), GFP_KERNEL);
>> + wl = kzalloc(sizeof(struct wilc), GFP_KERNEL);
>> if (!wl)
>> return -ENOMEM;
prev parent reply other threads:[~2016-05-27 18:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-27 17:51 [PATCH] staging/wilc1000: fixes kzalloc call Lidza Louina
2016-05-27 18:07 ` Joe Perches
2016-05-27 18:24 ` Lidza Louina [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=574890E6.4000600@oracle.com \
--to=lidza.louina@oracle.com \
--cc=austin.shin@atmel.com \
--cc=chris.park@atmel.com \
--cc=devel@driverdev.osuosl.org \
--cc=glen.lee@atmel.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=johnny.kim@atmel.com \
--cc=leo.kim@atmel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=tony.cho@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).