opal: prd_info: NULLify output after free

Submitted by Colin King on April 21, 2017, 10:04 a.m.

Details

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

Commit Message

Colin King April 21, 2017, 10:04 a.m.
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.
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>

Patch hide | download patch | download mbox

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 */