All of lore.kernel.org
 help / color / mirror / Atom feed
* [Devel] AcpiOsAllocate with zero argument
@ 2016-07-27 16:53 Rudolf Marek
  0 siblings, 0 replies; 3+ messages in thread
From: Rudolf Marek @ 2016-07-27 16:53 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 809 bytes --]

Hi all,

I could not find in the "ACPICA Overview and Programmer Reference" any clues 
what to do if someone calls AcpiOsAllocate() with size of zero. I checked the 
Linux implementation and it just calls kmalloc() which after bit of googling 
seems to return non-NULL for this case. I also tried to walk through the ACPICA 
sources and it seems to me that at least on some places it looks like that it 
could be called with 0 (num_gpe * sizeof(something))
I also tried to look to the "osdeps" of what the UEFI or unix stub do, but they 
simply pass it on. I could not find what UEFI does with zero, I only know
that malloc can either return NULL (and success) or return also non-null pointer.

What is the correct way to handle the zero size allocations? Return non-NULL ?

Thanks
Rudolf



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Devel] AcpiOsAllocate with zero argument
@ 2016-07-28  8:06 Rudolf Marek
  0 siblings, 0 replies; 3+ messages in thread
From: Rudolf Marek @ 2016-07-28  8:06 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Hi Lv,

Thanks for the quick response. I checked the Linux kmalloc() and also UEFI 
AllocatePool() and they accept the zero size. No NULL is returned.

Therefore I would like to ask if it can be documented in the Programming Manual 
that zero size should be OK and
non-NULL value should be returned. Otherwise, it may happen that if 
implementation of  AcpiOsAllocate() returns NULL and maybe there is some check 
in the ACPICA code which will complain and break things.

As for the free() you mean that NULL should be ignored?

Thanks
Rudolf


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Devel] AcpiOsAllocate with zero argument
@ 2016-07-28  5:29 Zheng, Lv
  0 siblings, 0 replies; 3+ messages in thread
From: Zheng, Lv @ 2016-07-28  5:29 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 1522 bytes --]

Hi, Rudolf

> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Rudolf Marek
> Subject: [Devel] AcpiOsAllocate with zero argument
> 
> Hi all,
> 
> I could not find in the "ACPICA Overview and Programmer Reference" any
> clues
> what to do if someone calls AcpiOsAllocate() with size of zero. I checked
> the
> Linux implementation and it just calls kmalloc() which after bit of googling
> seems to return non-NULL for this case. I also tried to walk through the
> ACPICA
> sources and it seems to me that at least on some places it looks like that it
> could be called with 0 (num_gpe * sizeof(something))
> I also tried to look to the "osdeps" of what the UEFI or unix stub do, but
> they
> simply pass it on. I could not find what UEFI does with zero, I only know
> that malloc can either return NULL (and success) or return also non-null
> pointer.
> 
> What is the correct way to handle the zero size allocations? Return non-
> NULL ?
[Lv Zheng] 
IMO, there is no strict rule against the returning value of AcpiOsAllocate().
But there is an implied rule against AcpiOsFree() (IMO, should be documented in ACPICA reference manual).
That is:
If NULL is passed to AcpiOsFree(), program crash shouldn't be resulted.
For AcpiOsFree() implemented for UEFI, BS->FreePool() returns EFI_INVALID_PARAMETER.
So it is compliant to this rule.

However, if you can see practical issues around these 2 functions, please let us know.
We should fix all kinds of such issues.

Thanks
Lv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-28  8:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-27 16:53 [Devel] AcpiOsAllocate with zero argument Rudolf Marek
2016-07-28  5:29 Zheng, Lv
2016-07-28  8:06 Rudolf Marek

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.