Re: [PATCH v2] KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

From: Amit Machhiwal

Date: Wed Sep 16 2026 - 13:29:45 EST


On 2026/09/16 09:07 PM, Bui Nguyen Nhu Quynh wrote:
> The kvmppc_gsm_refresh_info() function incorrectly checks for the
> presence of the fill_info callback instead of refresh_info.
>
> This can lead to:
> - NULL pointer dereference if refresh_info is NULL but fill_info is present
> - EINVAL return if refresh_info is present but fill_info is NULL
>
> Fix this by checking the correct callback.
>
> Fixes: 6ccbbc33f06ad ("KVM: PPC: Add helper library for Guest State Buffers")
> Signed-off-by: Bui Nguyen Nhu Quynh <kaylovefoss@xxxxxxxxx>
> ---
> v2:
> - Resend; v1 was mangled by the mail client. No code changes.
>
> arch/powerpc/kvm/guest-state-buffer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/guest-state-buffer.c b/arch/powerpc/kvm/guest-state-buffer.c
> index 42843eca6727..aeb586ba4523 100644
> --- a/arch/powerpc/kvm/guest-state-buffer.c
> +++ b/arch/powerpc/kvm/guest-state-buffer.c
> @@ -598,7 +598,7 @@ EXPORT_SYMBOL_GPL(kvmppc_gsm_fill_info);
> int kvmppc_gsm_refresh_info(struct kvmppc_gs_msg *gsm,
> struct kvmppc_gs_buff *gsb)

The fix is correct.

However, the patch still does not apply cleanly:

$ git apply ./v2_...mbx --check --verbose
error: patch failed: arch/powerpc/kvm/guest-state-buffer.c:598
error: arch/powerpc/kvm/guest-state-buffer.c: patch does not apply

The index line in the diff (42843eca6727) is a valid blob in the tree, so the
patch base is correct. The problem is that the context lines in the diff do not
match that blob. Concretely, the blob at 42843eca6727 has:

line 599: \t\t\t struct kvmppc_gs_buff *gsb) (3 tabs + 4 spaces)
line 601: \t\treturn -EINVAL; (2 tabs)

But the patch context has:

line 599: \t struct kvmppc_gs_buff *gsb) (1 tab + 4 spaces)
line 601: \treturn -EINVAL; (1 tab)

The indentation on those context lines is being collapsed during patch
generation. This points to a whitespace handling issue in your git
configuration.

Please review it and then regenerate with git format-patch and verify by
applying the generated patch file onto mainline. It'll also be a good idea to
rebase your patch on top of mainline before sending v3.

Thanks,
Amit

> {
> - if (!gsm->ops->fill_info)
> + if (!gsm->ops->refresh_info)
> return -EINVAL;
>
> return gsm->ops->refresh_info(gsm, gsb);
> --
> 2.54.0