All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Len Brown <lenb@kernel.org>, Shaohua Li <shaohua.li@intel.com>,
	Zhang Rui <rui.zhang@intel.com>,
	Zhao Yakui <yakui.zhao@intel.com>,
	linux-acpi@vger.kernel.org, vegardno@ifi.uio.no,
	casteyde.christian@free.fr
Subject: Re: [patch] acpi: silence kmemcheck false positive
Date: Tue, 27 Apr 2010 00:19:22 +0200	[thread overview]
Message-ID: <20100426221922.GW29093@bicker> (raw)
In-Reply-To: <201004221632.21129.bjorn.helgaas@hp.com>

On Thu, Apr 22, 2010 at 04:32:20PM -0600, Bjorn Helgaas wrote:
> > > -	event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
> > > +	event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC | __GFP_NOTRACK_FALSE_POSITIVE);
> 
> Just in terms of reading the code, this solution is fairly ugly.
> I think __GFP_NOTRACK should be sort of the last resort, after we've
> ruled out all the more conventional strategies.
> 
> Has anybody tried any of the alternatives Vegard suggested here:
> https://bugzilla.kernel.org/show_bug.cgi?id=14998#c35 ?
> 

First of all I really want to thank Vegard for taking the time to look
at this.  There are three options in the bugzilla entry:

> 1. Copy the struct "by hand" and use strncpy() for the strings to avoid
> the uninitialized areas.

The downside is that copying by hand is a maintainance hassle.

> 2. Allocate the event with kmalloc() instead of on the stack and free it
> after the call to acpi_bus_receive_event().

The problem with this is that if a future function uses stack data instead
of allocated data we're back at square one.  Perhaps if we put a huge 
warning sign it would be OK.  There isn't a sparse anotation for this, 
but it would be nice to have.  One other place where we could use it 
would be passing stack space as a DMA transfer buffer.

> 3. Allocate the event with kmalloc() and pass ownership of the structure
> to acpi_bus_receive_event() to avoid the copying altogether.
                                                                                                                             
I don't think the kmalloc() is meant here because it says we avoid the 
copying.  This is a simple api change but in the end I didn't think it
was as nice as the current api.  I did write a patch to do it though so
if anyone prefers that I can send it.

In the end, I decided it was easiest to just to change the kmalloc() to a
kzalloc().

regards,
dan carpenter


  parent reply	other threads:[~2010-04-26 22:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-22 19:43 [patch] acpi: silence kmemcheck false positive Dan Carpenter
2010-04-22 20:02 ` Dan Carpenter
2010-04-22 22:32   ` Bjorn Helgaas
2010-04-23 19:17     ` Dan Carpenter
2010-04-26 22:19     ` Dan Carpenter [this message]
2010-04-26 22:23     ` [patch v2] " Dan Carpenter
2010-04-27  7:15       ` Len Brown

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=20100426221922.GW29093@bicker \
    --to=error27@gmail.com \
    --cc=bjorn.helgaas@hp.com \
    --cc=casteyde.christian@free.fr \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=shaohua.li@intel.com \
    --cc=vegardno@ifi.uio.no \
    --cc=yakui.zhao@intel.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.