Re: [PATCH v2] KVM: SVM: Fix "error" isn't initialized

From: linmiaohe
Date: Wed Nov 27 2019 - 03:47:10 EST


> From e7f9c786e43ef4f890b8a01f15f8f00786f4b14a Mon Sep 17 00:00:00 2001
> From: Haiwei Li <lihaiwei@xxxxxxxxxxx>
> Date: Wed, 27 Nov 2019 15:00:49 +0800
> Subject: [PATCH v2] fix: 'error' is not initialized
>
> There are a bunch of error paths were "error" isn't initialized.
> @@ -155,6 +155,8 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
> unsigned int phys_lsb, phys_msb;
> unsigned int reg, ret = 0;
>
> + *psp_ret = -1;
> +
> if (!psp)
> return -ENODEV;
>

The arg psp_ret may be NULL in some path such as sev_guest_df_flush(NULL).
So you have to check it against NULL.
Thanks.