All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Lidza Louina <lidza.louina@oracle.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 11:07:40 -0700	[thread overview]
Message-ID: <1464372460.3938.13.camel@perches.com> (raw)
In-Reply-To: <1464371477-16965-1-git-send-email-lidza.louina@oracle.com>

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), ...);

> 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;

  reply	other threads:[~2016-05-27 18:07 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 [this message]
2016-05-27 18:24   ` Lidza Louina

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=1464372460.3938.13.camel@perches.com \
    --to=joe@perches.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=johnny.kim@atmel.com \
    --cc=leo.kim@atmel.com \
    --cc=lidza.louina@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.