Skip to contentSkip to conversation

KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

PATCH In review [email protected] 5 participants 9 messages Sep 1 – Sep 29

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

From 80fd05e6d156d5a90d4908f2498bf6cc7acbdefd Mon Sep 17 00:00:00 2001
From: Bui Nguyen Nhu Quynh <[email protected]>
Date: Tue, 1 Sep 2026 19:39:49 +0700
Subject: [PATCH] KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

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")

---
arch/powerpc/kvm/guest-state-buffer.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/guest-state-buffer.c +0 -0
index 42843eca6727..aeb586ba4523 100644
@@ -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)
{
- if (!gsm->ops->fill_info)
+ if (!gsm->ops->refresh_info)
return -EINVAL;

return gsm->ops->refresh_info(gsm, gsb);
--
2.54.0

#1 lore raw
Quoted 5 lines · On Tue, Sep 01, 2026 at 03:26:56PM +0200, [email protected] wrote:

From 80fd05e6d156d5a90d4908f2498bf6cc7acbdefd Mon Sep 17 00:00:00 2001
From: Bui Nguyen Nhu Quynh <[email protected]>
Date: Tue, 1 Sep 2026 19:39:49 +0700
Subject: [PATCH] KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

This should not be in the patch description.

Quoted 26 lines

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")

---
arch/powerpc/kvm/guest-state-buffer.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/guest-state-buffer.c +1 -1
index 42843eca6727..aeb586ba4523 100644
@@ -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)
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 return -EINVAL;
Quoted 4 lines


return gsm->ops->refresh_info(gsm, gsb);
--
2.54.0

This patch does not apply

# git apply 20260901_nhuquynh_kvm_ppc_fix_callback_check_in_kvmppc_gsm_refresh_info.mbx --check --verbose
error: corrupt patch at 20260901_nhuquynh_kvm_ppc_fix_callback_check_in_kvmppc_gsm_refresh_info.mbx:30

The change itself is fine, but please fix the above issues and send a v2. Refer the documentation in case something is not clear -
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

Thanks,
Gautam

#2 lore raw
In reply to [email protected]
Quoted 25 lines · On 2026/09/01 03:26 PM, [email protected] wrote:

From 80fd05e6d156d5a90d4908f2498bf6cc7acbdefd Mon Sep 17 00:00:00 2001
From: Bui Nguyen Nhu Quynh <[email protected]>
Date: Tue, 1 Sep 2026 19:39:49 +0700
Subject: [PATCH] KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

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")

---
arch/powerpc/kvm/guest-state-buffer.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/guest-state-buffer.c +0 -0
index 42843eca6727..aeb586ba4523 100644

arch/powerpc/kvm/guest-state-buffer.c EXPORT_SYMBOL_GPL(kvmppc_gsm_fill_info); · line 602

Quoted 6 lines
arch/powerpc/kvm/guest-state-buffer.c +1 -1
@@ -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)
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 return -EINVAL;

Thanks for catching this.

The patch appears corrupted by your email client (whitespace mangling / quoted-printable encoding).

❯ git apply ./20260901_nhuquynh_kvm_ppc_fix_callback_check_in_kvmppc_gsm_refresh_info.mbx
error: corrupt patch at line 30

Please consider configuring and using git send-email to submit v2.

Thanks,
Amit

Quoted 4 lines


return gsm->ops->refresh_info(gsm, gsb);
--
2.54.0

#3 lore raw

PATCH v2 1/1 KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

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")

---
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(-)
arch/powerpc/kvm/guest-state-buffer.c +1 -1
index 42843eca6727..aeb586ba4523 100644
@@ -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)
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 	return -EINVAL;
 
 	return gsm->ops->refresh_info(gsm, gsb);
Signature · 1 line
2.54.0
#4 lore raw
Quoted 23 lines · Bui Nguyen Nhu Quynh

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")

---
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(-)
arch/powerpc/kvm/guest-state-buffer.c +0 -0
index 42843eca6727..aeb586ba4523 100644

arch/powerpc/kvm/guest-state-buffer.c EXPORT_SYMBOL_GPL(kvmppc_gsm_fill_info); · line 599

Quoted 2 lines
arch/powerpc/kvm/guest-state-buffer.c +0 -0
@@ -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

Quoted 8 lines
arch/powerpc/kvm/guest-state-buffer.c +1 -1
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 	return -EINVAL;
 
 	return gsm->ops->refresh_info(gsm, gsb);
Signature · 1 line
2.54.0
#5 lore raw

PATCH v3 1/1 KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

In reply to Amit Machhiwal

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")

---
v3:
- Resend to fix whitespace handling issue on v2. No code changes.

 arch/powerpc/kvm/guest-state-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/guest-state-buffer.c +1 -1
index 42843eca6727..aeb586ba4523 100644
@@ -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)
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 		return -EINVAL;
 
 	return gsm->ops->refresh_info(gsm, gsb);
Signature · 1 line
2.54.0
Reviewed-by on v3 1/1
#6 lore raw
Quoted 7 lines · Bui Nguyen Nhu Quynh

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

Quoted 7 lines

Fix this by checking the correct callback.

Fixes 6ccbbc33f06ad ("KVM: PPC: Add helper library for Guest State Buffers")

---
v3:
- Resend to fix whitespace handling issue on v2. No code changes.

Thanks for fixing the spacing issues. The patch applies fine now.

Thanks,
Amit

Quoted 20 lines
 arch/powerpc/kvm/guest-state-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/guest-state-buffer.c +1 -1
index 42843eca6727..aeb586ba4523 100644
@@ -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)
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 		return -EINVAL;
 
 	return gsm->ops->refresh_info(gsm, gsb);
Signature · 1 line
2.54.0
Tested-by on v3 1/1
#7 lore raw
In reply to Bui Nguyen Nhu Quynh
Quoted 7 lines · Bui Nguyen Nhu Quynh

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

Quoted 8 lines

Fix this by checking the correct callback.

Fixes 6ccbbc33f06ad ("KVM: PPC: Add helper library for Guest State Buffers")

---
v3:
- Resend to fix whitespace handling issue on v2. No code changes.

You missed the v2 changelog here. You should mention all changes introduced in every version.

Quoted 20 lines
 arch/powerpc/kvm/guest-state-buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/guest-state-buffer.c +1 -1
index 42843eca6727..aeb586ba4523 100644
@@ -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)
 {
-	if (!gsm->ops->fill_info)
+	if (!gsm->ops->refresh_info)
 		return -EINVAL;
 
 	return gsm->ops->refresh_info(gsm, gsb);
Signature · 1 line
2.54.0

LGTM, this is a copy paste mistake. I did some quick sanity test with this patch applied.

maintainer Applied
#8 lore raw
In reply to Bui Nguyen Nhu Quynh
Quoted 8 lines · Bui Nguyen Nhu Quynh

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

[...]

Applied to powerpc/next.

[1/1] KVM: PPC: Fix callback check in kvmppc_gsm_refresh_info

      https://git.kernel.org/powerpc/c/a7ea67879af09438d38032107b89a62739b09e96

cheers