All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Devel] [PATCH] Check for failed string allocation and set Status accordingly
@ 2016-03-24 17:24 Colin Ian King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin Ian King @ 2016-03-24 17:24 UTC (permalink / raw)
  To: devel

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

On 24/03/16 17:18, Moore, Robert wrote:
> The "temporary" part is true. We were using the code block to test the ExternalOp that came from ACPi 6.0.
> 
> In truth, the interpreter should never see an external opcode because it will be surrounded by an If(0) conditional. So, the code block in question should probably go away completely.
> 
> Bob

OK, so either this code gets ripped out, or we fix it with the small
fix, at least either way we clean up the code.

Colin

> 
> 
>> -----Original Message-----
>> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Colin King
>> Sent: Tuesday, March 22, 2016 3:17 PM
>> To: devel(a)acpica.org
>> Subject: [Devel] [PATCH] Check for failed string allocation and set Status
>> accordingly
>>
>> From: Colin Ian King <colin.king(a)canonical.com>
>>
>> It is possible that AcpiUtCreateStringObject fails to allocate a string
>> object, so check for this condition and set Status to AE_NO_MEMORY to
>> indicate a memory allocation failure.
>>
>> Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
>> ---
>>  source/components/dispatcher/dsutils.c | 12 +++++++++---
>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/source/components/dispatcher/dsutils.c
>> b/source/components/dispatcher/dsutils.c
>> index 52e9ca8..124dc67 100644
>> --- a/source/components/dispatcher/dsutils.c
>> +++ b/source/components/dispatcher/dsutils.c
>> @@ -678,9 +678,15 @@ AcpiDsCreateOperand (
>>                      /* TBD: May only be temporary */
>>
>>                      ObjDesc = AcpiUtCreateStringObject ((ACPI_SIZE)
>> NameLength);
>> -
>> -                    strncpy (ObjDesc->String.Pointer, NameString,
>> NameLength);
>> -                    Status = AE_OK;
>> +                    if (!ObjDesc)
>> +                    {
>> +                        Status = AE_NO_MEMORY;
>> +                    }
>> +                    else
>> +                    {
>> +                        strncpy (ObjDesc->String.Pointer, NameString,
>> NameLength);
>> +                        Status = AE_OK;
>> +                    }
>>                  }
>>                  else
>>                  {
>> --
>> 2.7.3
>>
>> _______________________________________________
>> Devel mailing list
>> Devel(a)acpica.org
>> https://lists.acpica.org/mailman/listinfo/devel


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

* Re: [Devel] [PATCH] Check for failed string allocation and set Status accordingly
@ 2016-03-24 17:18 Moore, Robert
  0 siblings, 0 replies; 3+ messages in thread
From: Moore, Robert @ 2016-03-24 17:18 UTC (permalink / raw)
  To: devel

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

The "temporary" part is true. We were using the code block to test the ExternalOp that came from ACPi 6.0.

In truth, the interpreter should never see an external opcode because it will be surrounded by an If(0) conditional. So, the code block in question should probably go away completely.

Bob


> -----Original Message-----
> From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Colin King
> Sent: Tuesday, March 22, 2016 3:17 PM
> To: devel(a)acpica.org
> Subject: [Devel] [PATCH] Check for failed string allocation and set Status
> accordingly
> 
> From: Colin Ian King <colin.king(a)canonical.com>
> 
> It is possible that AcpiUtCreateStringObject fails to allocate a string
> object, so check for this condition and set Status to AE_NO_MEMORY to
> indicate a memory allocation failure.
> 
> Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
> ---
>  source/components/dispatcher/dsutils.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/source/components/dispatcher/dsutils.c
> b/source/components/dispatcher/dsutils.c
> index 52e9ca8..124dc67 100644
> --- a/source/components/dispatcher/dsutils.c
> +++ b/source/components/dispatcher/dsutils.c
> @@ -678,9 +678,15 @@ AcpiDsCreateOperand (
>                      /* TBD: May only be temporary */
> 
>                      ObjDesc = AcpiUtCreateStringObject ((ACPI_SIZE)
> NameLength);
> -
> -                    strncpy (ObjDesc->String.Pointer, NameString,
> NameLength);
> -                    Status = AE_OK;
> +                    if (!ObjDesc)
> +                    {
> +                        Status = AE_NO_MEMORY;
> +                    }
> +                    else
> +                    {
> +                        strncpy (ObjDesc->String.Pointer, NameString,
> NameLength);
> +                        Status = AE_OK;
> +                    }
>                  }
>                  else
>                  {
> --
> 2.7.3
> 
> _______________________________________________
> Devel mailing list
> Devel(a)acpica.org
> https://lists.acpica.org/mailman/listinfo/devel

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

* [Devel] [PATCH] Check for failed string allocation and set Status accordingly
@ 2016-03-22 22:16 Colin King
  0 siblings, 0 replies; 3+ messages in thread
From: Colin King @ 2016-03-22 22:16 UTC (permalink / raw)
  To: devel

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

From: Colin Ian King <colin.king(a)canonical.com>

It is possible that AcpiUtCreateStringObject fails to allocate a
string object, so check for this condition and set Status to
AE_NO_MEMORY to indicate a memory allocation failure.

Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
 source/components/dispatcher/dsutils.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/source/components/dispatcher/dsutils.c b/source/components/dispatcher/dsutils.c
index 52e9ca8..124dc67 100644
--- a/source/components/dispatcher/dsutils.c
+++ b/source/components/dispatcher/dsutils.c
@@ -678,9 +678,15 @@ AcpiDsCreateOperand (
                     /* TBD: May only be temporary */
 
                     ObjDesc = AcpiUtCreateStringObject ((ACPI_SIZE) NameLength);
-
-                    strncpy (ObjDesc->String.Pointer, NameString, NameLength);
-                    Status = AE_OK;
+                    if (!ObjDesc)
+                    {
+                        Status = AE_NO_MEMORY;
+                    }
+                    else
+                    {
+                        strncpy (ObjDesc->String.Pointer, NameString, NameLength);
+                        Status = AE_OK;
+                    }
                 }
                 else
                 {
-- 
2.7.3


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

end of thread, other threads:[~2016-03-24 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-24 17:24 [Devel] [PATCH] Check for failed string allocation and set Status accordingly Colin Ian King
  -- strict thread matches above, loose matches on Subject: below --
2016-03-24 17:18 Moore, Robert
2016-03-22 22:16 Colin King

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.