Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 117319
b: refs/heads/master
c: 68e125c
h: refs/heads/master
i:
  117317: ec7600f
  117315: 5e8f218
  117311: 8404386
v: v3
  • Loading branch information
Bob Moore authored and Len Brown committed Oct 23, 2008
1 parent a26c7ef commit 3cdb0ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cf058bd1c84df9921ecc517d8a8a413f4d6b5b45
refs/heads/master: 68e125c40597802b9789bc696775bf0246e7667d
53 changes: 28 additions & 25 deletions trunk/drivers/acpi/utilities/utalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,71 +232,74 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
* RETURN: Status
*
* DESCRIPTION: Validate that the buffer is of the required length or
* allocate a new buffer. Returned buffer is always zeroed.
* allocate a new buffer. Returned buffer is always zeroed.
*
******************************************************************************/

acpi_status
acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
acpi_size required_length)
{
acpi_status status = AE_OK;
acpi_size input_buffer_length;

/* Parameter validation */

if (!buffer || !required_length) {
return (AE_BAD_PARAMETER);
}

switch (buffer->length) {
/*
* Buffer->Length is used as both an input and output parameter. Get the
* input actual length and set the output required buffer length.
*/
input_buffer_length = buffer->length;
buffer->length = required_length;

/*
* The input buffer length contains the actual buffer length, or the type
* of buffer to be allocated by this routine.
*/
switch (input_buffer_length) {
case ACPI_NO_BUFFER:

/* Set the exception and returned the required length */
/* Return the exception (and the required buffer length) */

status = AE_BUFFER_OVERFLOW;
break;
return (AE_BUFFER_OVERFLOW);

case ACPI_ALLOCATE_BUFFER:

/* Allocate a new buffer */

buffer->pointer = acpi_os_allocate(required_length);
if (!buffer->pointer) {
return (AE_NO_MEMORY);
}

/* Clear the buffer */

ACPI_MEMSET(buffer->pointer, 0, required_length);
break;

case ACPI_ALLOCATE_LOCAL_BUFFER:

/* Allocate a new buffer with local interface to allow tracking */

buffer->pointer = ACPI_ALLOCATE_ZEROED(required_length);
if (!buffer->pointer) {
return (AE_NO_MEMORY);
}
buffer->pointer = ACPI_ALLOCATE(required_length);
break;

default:

/* Existing buffer: Validate the size of the buffer */

if (buffer->length < required_length) {
status = AE_BUFFER_OVERFLOW;
break;
if (input_buffer_length < required_length) {
return (AE_BUFFER_OVERFLOW);
}
break;
}

/* Clear the buffer */
/* Validate allocation from above or input buffer pointer */

ACPI_MEMSET(buffer->pointer, 0, required_length);
break;
if (!buffer->pointer) {
return (AE_NO_MEMORY);
}

buffer->length = required_length;
return (status);
/* Have a valid buffer, clear it */

ACPI_MEMSET(buffer->pointer, 0, required_length);
return (AE_OK);
}

#ifdef NOT_USED_BY_LINUX
Expand Down

0 comments on commit 3cdb0ec

Please sign in to comment.