acpi: syntaxcheck: nullify pointers to clean up static analysis warnings
diff mbox series

Message ID 20190610112634.23055-1-colin.king@canonical.com
State Accepted
Headers show
Series
  • acpi: syntaxcheck: nullify pointers to clean up static analysis warnings
Related show

Commit Message

Colin King June 10, 2019, 11:26 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The fwts_iasl_reassemble call potentially may not set the iasl_stdout,
iasl_stderr and iasl_disassembly pointers, so initialize these to NULL
so that the fwts_text_list_free calls won't hit uninitialized pointer
reads if fwts_iasl_reassemble fails.

Addresses-Coverity: ("Uninitialized pointer read")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/syntaxcheck/syntaxcheck.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Alex Hung June 10, 2019, 8:30 p.m. UTC | #1
On 2019-06-10 4:26 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The fwts_iasl_reassemble call potentially may not set the iasl_stdout,
> iasl_stderr and iasl_disassembly pointers, so initialize these to NULL
> so that the fwts_text_list_free calls won't hit uninitialized pointer
> reads if fwts_iasl_reassemble fails.
> 
> Addresses-Coverity: ("Uninitialized pointer read")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/syntaxcheck/syntaxcheck.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 03a28b2c..8ba1dc2f 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -495,7 +495,9 @@ static int syntaxcheck_single_table(
>  	int errors = 0;
>  	int warnings = 0;
>  	int remarks = 0;
> -	fwts_list *iasl_stdout, *iasl_stderr, *iasl_disassembly;
> +	fwts_list *iasl_stdout = NULL,
> +		  *iasl_stderr = NULL,
> +		  *iasl_disassembly = NULL;
>  
>  	if (fwts_iasl_reassemble(fw, info,
>  		&iasl_disassembly, &iasl_stdout, &iasl_stderr) != FWTS_OK) {
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan June 11, 2019, 5:45 a.m. UTC | #2
On 6/10/19 7:26 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The fwts_iasl_reassemble call potentially may not set the iasl_stdout,
> iasl_stderr and iasl_disassembly pointers, so initialize these to NULL
> so that the fwts_text_list_free calls won't hit uninitialized pointer
> reads if fwts_iasl_reassemble fails.
>
> Addresses-Coverity: ("Uninitialized pointer read")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/syntaxcheck/syntaxcheck.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
> index 03a28b2c..8ba1dc2f 100644
> --- a/src/acpi/syntaxcheck/syntaxcheck.c
> +++ b/src/acpi/syntaxcheck/syntaxcheck.c
> @@ -495,7 +495,9 @@ static int syntaxcheck_single_table(
>  	int errors = 0;
>  	int warnings = 0;
>  	int remarks = 0;
> -	fwts_list *iasl_stdout, *iasl_stderr, *iasl_disassembly;
> +	fwts_list *iasl_stdout = NULL,
> +		  *iasl_stderr = NULL,
> +		  *iasl_disassembly = NULL;
>  
>  	if (fwts_iasl_reassemble(fw, info,
>  		&iasl_disassembly, &iasl_stdout, &iasl_stderr) != FWTS_OK) {


Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch
diff mbox series

diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c
index 03a28b2c..8ba1dc2f 100644
--- a/src/acpi/syntaxcheck/syntaxcheck.c
+++ b/src/acpi/syntaxcheck/syntaxcheck.c
@@ -495,7 +495,9 @@  static int syntaxcheck_single_table(
 	int errors = 0;
 	int warnings = 0;
 	int remarks = 0;
-	fwts_list *iasl_stdout, *iasl_stderr, *iasl_disassembly;
+	fwts_list *iasl_stdout = NULL,
+		  *iasl_stderr = NULL,
+		  *iasl_disassembly = NULL;
 
 	if (fwts_iasl_reassemble(fw, info,
 		&iasl_disassembly, &iasl_stdout, &iasl_stderr) != FWTS_OK) {