Re: [patch] acpi: silence kmemcheck false positive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux