diff mbox

opal: prd_info: NULLify output after free

Message ID 20170421100404.16350-1-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King April 21, 2017, 10:04 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

This fixes a static analysis warning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/opal/prd_info.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Alex Hung April 22, 2017, 3 p.m. UTC | #1
On 2017-04-21 03:04 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> This fixes a static analysis warning.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/opal/prd_info.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/opal/prd_info.c b/src/opal/prd_info.c
> index 04e0f4aa..bbaac408 100644
> --- a/src/opal/prd_info.c
> +++ b/src/opal/prd_info.c
> @@ -80,8 +80,10 @@ static int prd_service_check(fwts_framework *fw, int *restart)
>  	command = "systemctl status opal-prd.service 2>&1";
>  	status = fwts_exec2(command, &output);
>
> -	if (output)
> +	if (output) {
>  		free(output);
> +		output = NULL;
> +	}
>
>  	switch (status) {
>  	case -1: /* status when nothing was successful */
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu April 27, 2017, 6:35 a.m. UTC | #2
On 04/21/2017 06:04 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> This fixes a static analysis warning.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/opal/prd_info.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/opal/prd_info.c b/src/opal/prd_info.c
> index 04e0f4aa..bbaac408 100644
> --- a/src/opal/prd_info.c
> +++ b/src/opal/prd_info.c
> @@ -80,8 +80,10 @@ static int prd_service_check(fwts_framework *fw, int *restart)
>  	command = "systemctl status opal-prd.service 2>&1";
>  	status = fwts_exec2(command, &output);
>
> -	if (output)
> +	if (output) {
>  		free(output);
> +		output = NULL;
> +	}
>
>  	switch (status) {
>  	case -1: /* status when nothing was successful */
>

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

Patch

diff --git a/src/opal/prd_info.c b/src/opal/prd_info.c
index 04e0f4aa..bbaac408 100644
--- a/src/opal/prd_info.c
+++ b/src/opal/prd_info.c
@@ -80,8 +80,10 @@  static int prd_service_check(fwts_framework *fw, int *restart)
 	command = "systemctl status opal-prd.service 2>&1";
 	status = fwts_exec2(command, &output);
 
-	if (output)
+	if (output) {
 		free(output);
+		output = NULL;
+	}
 
 	switch (status) {
 	case -1: /* status when nothing was successful */