public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Joonwoo Park <joonwpark81@gmail.com>
Cc: netdev@vger.kernel.org, chas@cmf.nrl.navy.mil,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] atm/ambassador: kmalloc + memset conversion to kzalloc
Date: Mon, 26 Nov 2007 04:11:49 -0500 (EST)	[thread overview]
Message-ID: <alpine.LFD.0.9999.0711260409110.551@localhost.localdomain> (raw)
In-Reply-To: <007f01c8300b$1b89ac40$9c94fea9@jason>

On Mon, 26 Nov 2007, Joonwoo Park wrote:

> atm/ambassador: kmalloc + memset conversion to kzalloc
>
> Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
>
> Thanks.
> Joonwoo
>
> ---
> diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
> index b34b382..4f99ba3 100644
> --- a/drivers/atm/ambassador.c
> +++ b/drivers/atm/ambassador.c
> @@ -2163,7 +2163,6 @@ static int __devinit amb_init (amb_dev * dev)
>  static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
>  {
>        unsigned char pool;
> -      memset (dev, 0, sizeof(amb_dev));
>
>        // set up known dev items straight away
>        dev->pci_dev = pci_dev;
> @@ -2253,7 +2252,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
>  		goto out_disable;
>  	}
>
> -	dev = kmalloc (sizeof(amb_dev), GFP_KERNEL);
> +	dev = kzalloc(sizeof(amb_dev), GFP_KERNEL);
>  	if (!dev) {
>  		PRINTK (KERN_ERR, "out of memory!");
>  		err = -ENOMEM;
> ---

i'm not sure the above is a safe thing to do, as you're zeroing that
area, then making a function call and assuming, upon entry to the
function call, that the caller has done the right thing.  i don't see
how you can count on that, depending on who else might want to call
that routine and whether they get sloppy about it.  unless you're
prepared to guarantee that there will never be another call to
setup_dev() from elsewhere.


rday


========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

  reply	other threads:[~2007-11-26  9:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26  9:02 [PATCH 4/4] atm/ambassador: kmalloc + memset conversion to kzalloc Joonwoo Park
2007-11-26  9:11 ` Robert P. J. Day [this message]
2007-11-26 10:23   ` Joonwoo Park
2007-11-26 10:29     ` Robert P. J. Day
2007-11-26 10:53       ` Joonwoo Park
2007-11-26 11:20         ` Robert P. J. Day
2007-11-27 14:40           ` chas williams - CONTRACTOR

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=alpine.LFD.0.9999.0711260409110.551@localhost.localdomain \
    --to=rpjday@crashcourse.ca \
    --cc=chas@cmf.nrl.navy.mil \
    --cc=joonwpark81@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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