diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-23 13:20:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-23 13:20:36 -0400 |
| commit | 765426e8ee4c0ab2bc9d44951f4865b8494cdbd0 (patch) | |
| tree | 2b46ab8953eff175c8d3474a9754c1ab1394e4de /drivers/acpi/utilities/utalloc.c | |
| parent | 36ec891895020f3bc9953c8b11d079c6d77d76bd (diff) | |
| parent | 898b054f3eec5921320ae8614b5bdd7b07ea5b43 (diff) | |
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6
* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6: (123 commits)
dock: make dock driver not a module
ACPI: fix ia64 build warning
ACPI: hack around sysfs warning with link order
ACPI suspend: fix build warning when CONFIG_ACPI_SLEEP=n
intel_menlo: fix build warning
panasonic-laptop: fix build
ACPICA: Update version to 20080926
ACPICA: Add support for zero-length buffer-to-string conversions
ACPICA: New: Validation for predefined ACPI methods/objects
ACPICA: Fix for implicit return compatibility
ACPICA: Fixed a couple memory leaks associated with "implicit return"
ACPICA: Optimize buffer allocation procedure
ACPICA: Fix possible memory leak, error exit path
ACPICA: Fix fault after mem allocation failure in AML parser
ACPICA: Remove unused ACPI register bit definition
ACPICA: Update version to 20080829
ACPICA: Fix possible memory leak in acpi_ns_get_external_pathname
ACPICA: Cleanup for internal Reference Object
ACPICA: Update comments - no functional changes
ACPICA: Update for Reference ACPI_OPERAND_OBJECT
...
Diffstat (limited to 'drivers/acpi/utilities/utalloc.c')
| -rw-r--r-- | drivers/acpi/utilities/utalloc.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c index 7dcb67e0b21..241c535c175 100644 --- a/drivers/acpi/utilities/utalloc.c +++ b/drivers/acpi/utilities/utalloc.c | |||
| @@ -232,7 +232,7 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer) | |||
| 232 | * RETURN: Status | 232 | * RETURN: Status |
| 233 | * | 233 | * |
| 234 | * DESCRIPTION: Validate that the buffer is of the required length or | 234 | * DESCRIPTION: Validate that the buffer is of the required length or |
| 235 | * allocate a new buffer. Returned buffer is always zeroed. | 235 | * allocate a new buffer. Returned buffer is always zeroed. |
| 236 | * | 236 | * |
| 237 | ******************************************************************************/ | 237 | ******************************************************************************/ |
| 238 | 238 | ||
| @@ -240,7 +240,7 @@ acpi_status | |||
| 240 | acpi_ut_initialize_buffer(struct acpi_buffer * buffer, | 240 | acpi_ut_initialize_buffer(struct acpi_buffer * buffer, |
| 241 | acpi_size required_length) | 241 | acpi_size required_length) |
| 242 | { | 242 | { |
| 243 | acpi_status status = AE_OK; | 243 | acpi_size input_buffer_length; |
| 244 | 244 | ||
| 245 | /* Parameter validation */ | 245 | /* Parameter validation */ |
| 246 | 246 | ||
| @@ -248,55 +248,58 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer, | |||
| 248 | return (AE_BAD_PARAMETER); | 248 | return (AE_BAD_PARAMETER); |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | switch (buffer->length) { | 251 | /* |
| 252 | * Buffer->Length is used as both an input and output parameter. Get the | ||
| 253 | * input actual length and set the output required buffer length. | ||
| 254 | */ | ||
| 255 | input_buffer_length = buffer->length; | ||
| 256 | buffer->length = required_length; | ||
| 257 | |||
| 258 | /* | ||
| 259 | * The input buffer length contains the actual buffer length, or the type | ||
| 260 | * of buffer to be allocated by this routine. | ||
| 261 | */ | ||
| 262 | switch (input_buffer_length) { | ||
| 252 | case ACPI_NO_BUFFER: | 263 | case ACPI_NO_BUFFER: |
| 253 | 264 | ||
| 254 | /* Set the exception and returned the required length */ | 265 | /* Return the exception (and the required buffer length) */ |
| 255 | 266 | ||
| 256 | status = AE_BUFFER_OVERFLOW; | 267 | return (AE_BUFFER_OVERFLOW); |
| 257 | break; | ||
| 258 | 268 | ||
| 259 | case ACPI_ALLOCATE_BUFFER: | 269 | case ACPI_ALLOCATE_BUFFER: |
| 260 | 270 | ||
| 261 | /* Allocate a new buffer */ | 271 | /* Allocate a new buffer */ |
| 262 | 272 | ||
| 263 | buffer->pointer = acpi_os_allocate(required_length); | 273 | buffer->pointer = acpi_os_allocate(required_length); |
| 264 | if (!buffer->pointer) { | ||
| 265 | return (AE_NO_MEMORY); | ||
| 266 | } | ||
| 267 | |||
| 268 | /* Clear the buffer */ | ||
| 269 | |||
| 270 | ACPI_MEMSET(buffer->pointer, 0, required_length); | ||
| 271 | break; | 274 | break; |
| 272 | 275 | ||
| 273 | case ACPI_ALLOCATE_LOCAL_BUFFER: | 276 | case ACPI_ALLOCATE_LOCAL_BUFFER: |
| 274 | 277 | ||
| 275 | /* Allocate a new buffer with local interface to allow tracking */ | 278 | /* Allocate a new buffer with local interface to allow tracking */ |
| 276 | 279 | ||
| 277 | buffer->pointer = ACPI_ALLOCATE_ZEROED(required_length); | 280 | buffer->pointer = ACPI_ALLOCATE(required_length); |
| 278 | if (!buffer->pointer) { | ||
| 279 | return (AE_NO_MEMORY); | ||
| 280 | } | ||
| 281 | break; | 281 | break; |
| 282 | 282 | ||
| 283 | default: | 283 | default: |
| 284 | 284 | ||
| 285 | /* Existing buffer: Validate the size of the buffer */ | 285 | /* Existing buffer: Validate the size of the buffer */ |
| 286 | 286 | ||
| 287 | if (buffer->length < required_length) { | 287 | if (input_buffer_length < required_length) { |
| 288 | status = AE_BUFFER_OVERFLOW; | 288 | return (AE_BUFFER_OVERFLOW); |
| 289 | break; | ||
| 290 | } | 289 | } |
| 290 | break; | ||
| 291 | } | ||
| 291 | 292 | ||
| 292 | /* Clear the buffer */ | 293 | /* Validate allocation from above or input buffer pointer */ |
| 293 | 294 | ||
| 294 | ACPI_MEMSET(buffer->pointer, 0, required_length); | 295 | if (!buffer->pointer) { |
| 295 | break; | 296 | return (AE_NO_MEMORY); |
| 296 | } | 297 | } |
| 297 | 298 | ||
| 298 | buffer->length = required_length; | 299 | /* Have a valid buffer, clear it */ |
| 299 | return (status); | 300 | |
| 301 | ACPI_MEMSET(buffer->pointer, 0, required_length); | ||
| 302 | return (AE_OK); | ||
| 300 | } | 303 | } |
| 301 | 304 | ||
| 302 | #ifdef NOT_USED_BY_LINUX | 305 | #ifdef NOT_USED_BY_LINUX |
