public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hv: utils: handle and propagate errors in kvp_register
@ 2026-04-14 11:10 Thorsten Blum
  2026-04-14 17:48 ` [EXTERNAL] " Long Li
  2026-04-29 12:27 ` Olaf Hering
  0 siblings, 2 replies; 6+ messages in thread
From: Thorsten Blum @ 2026-04-14 11:10 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Greg Kroah-Hartman
  Cc: Thorsten Blum, stable, Ky Srinivasan, linux-hyperv, linux-kernel

Make kvp_register() return an error code instead of silently ignoring
failures, and propagate the error from kvp_handle_handshake() instead of
returning success.

This propagates both kzalloc_obj() and hvutil_transport_send() failures
to kvp_handle_handshake() and thus to kvp_on_msg().

Fixes: 245ba56a52a3 ("Staging: hv: Implement key/value pair (KVP)")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/hv/hv_kvp.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 0d73daf745a7..6180ebe040ff 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -93,7 +93,7 @@ static void kvp_send_key(struct work_struct *dummy);
 static void kvp_respond_to_host(struct hv_kvp_msg *msg, int error);
 static void kvp_timeout_func(struct work_struct *dummy);
 static void kvp_host_handshake_func(struct work_struct *dummy);
-static void kvp_register(int);
+static int kvp_register(int);
 
 static DECLARE_DELAYED_WORK(kvp_timeout_work, kvp_timeout_func);
 static DECLARE_DELAYED_WORK(kvp_host_handshake_work, kvp_host_handshake_func);
@@ -127,24 +127,26 @@ static void kvp_register_done(void)
 	hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper);
 }
 
-static void
+static int
 kvp_register(int reg_value)
 {
 
 	struct hv_kvp_msg *kvp_msg;
 	char *version;
+	int ret;
 
 	kvp_msg = kzalloc_obj(*kvp_msg);
+	if (!kvp_msg)
+		return -ENOMEM;
 
-	if (kvp_msg) {
-		version = kvp_msg->body.kvp_register.version;
-		kvp_msg->kvp_hdr.operation = reg_value;
-		strcpy(version, HV_DRV_VERSION);
+	version = kvp_msg->body.kvp_register.version;
+	kvp_msg->kvp_hdr.operation = reg_value;
+	strcpy(version, HV_DRV_VERSION);
 
-		hvutil_transport_send(hvt, kvp_msg, sizeof(*kvp_msg),
-				      kvp_register_done);
-		kfree(kvp_msg);
-	}
+	ret = hvutil_transport_send(hvt, kvp_msg, sizeof(*kvp_msg),
+				    kvp_register_done);
+	kfree(kvp_msg);
+	return ret;
 }
 
 static void kvp_timeout_func(struct work_struct *dummy)
@@ -186,9 +188,8 @@ static int kvp_handle_handshake(struct hv_kvp_msg *msg)
 	 */
 	pr_debug("KVP: userspace daemon ver. %d connected\n",
 		 msg->kvp_hdr.operation);
-	kvp_register(dm_reg_value);
 
-	return 0;
+	return kvp_register(dm_reg_value);
 }
 
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [EXTERNAL] [PATCH] hv: utils: handle and propagate errors in kvp_register
  2026-04-14 11:10 [PATCH] hv: utils: handle and propagate errors in kvp_register Thorsten Blum
@ 2026-04-14 17:48 ` Long Li
  2026-04-29 22:15   ` Wei Liu
  2026-04-29 12:27 ` Olaf Hering
  1 sibling, 1 reply; 6+ messages in thread
From: Long Li @ 2026-04-14 17:48 UTC (permalink / raw)
  To: Thorsten Blum, KY Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
	Greg Kroah-Hartman
  Cc: stable@vger.kernel.org, Ky Srinivasan,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

> Make kvp_register() return an error code instead of silently ignoring failures, and
> propagate the error from kvp_handle_handshake() instead of returning success.
> 
> This propagates both kzalloc_obj() and hvutil_transport_send() failures to
> kvp_handle_handshake() and thus to kvp_on_msg().
> 
> Fixes: 245ba56a52a3 ("Staging: hv: Implement key/value pair (KVP)")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by:  Long Li <longli@microsoft.com>


> ---
>  drivers/hv/hv_kvp.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c index
> 0d73daf745a7..6180ebe040ff 100644
> --- a/drivers/hv/hv_kvp.c
> +++ b/drivers/hv/hv_kvp.c
> @@ -93,7 +93,7 @@ static void kvp_send_key(struct work_struct *dummy);
> static void kvp_respond_to_host(struct hv_kvp_msg *msg, int error);  static void
> kvp_timeout_func(struct work_struct *dummy);  static void
> kvp_host_handshake_func(struct work_struct *dummy); -static void
> kvp_register(int);
> +static int kvp_register(int);
> 
>  static DECLARE_DELAYED_WORK(kvp_timeout_work, kvp_timeout_func);  static
> DECLARE_DELAYED_WORK(kvp_host_handshake_work,
> kvp_host_handshake_func); @@ -127,24 +127,26 @@ static void
> kvp_register_done(void)
>  	hv_poll_channel(kvp_transaction.recv_channel, kvp_poll_wrapper);  }
> 
> -static void
> +static int
>  kvp_register(int reg_value)
>  {
> 
>  	struct hv_kvp_msg *kvp_msg;
>  	char *version;
> +	int ret;
> 
>  	kvp_msg = kzalloc_obj(*kvp_msg);
> +	if (!kvp_msg)
> +		return -ENOMEM;
> 
> -	if (kvp_msg) {
> -		version = kvp_msg->body.kvp_register.version;
> -		kvp_msg->kvp_hdr.operation = reg_value;
> -		strcpy(version, HV_DRV_VERSION);
> +	version = kvp_msg->body.kvp_register.version;
> +	kvp_msg->kvp_hdr.operation = reg_value;
> +	strcpy(version, HV_DRV_VERSION);
> 
> -		hvutil_transport_send(hvt, kvp_msg, sizeof(*kvp_msg),
> -				      kvp_register_done);
> -		kfree(kvp_msg);
> -	}
> +	ret = hvutil_transport_send(hvt, kvp_msg, sizeof(*kvp_msg),
> +				    kvp_register_done);
> +	kfree(kvp_msg);
> +	return ret;
>  }
> 
>  static void kvp_timeout_func(struct work_struct *dummy) @@ -186,9 +188,8
> @@ static int kvp_handle_handshake(struct hv_kvp_msg *msg)
>  	 */
>  	pr_debug("KVP: userspace daemon ver. %d connected\n",
>  		 msg->kvp_hdr.operation);
> -	kvp_register(dm_reg_value);
> 
> -	return 0;
> +	return kvp_register(dm_reg_value);
>  }
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hv: utils: handle and propagate errors in kvp_register
  2026-04-14 11:10 [PATCH] hv: utils: handle and propagate errors in kvp_register Thorsten Blum
  2026-04-14 17:48 ` [EXTERNAL] " Long Li
@ 2026-04-29 12:27 ` Olaf Hering
  2026-04-29 12:36   ` Thorsten Blum
  1 sibling, 1 reply; 6+ messages in thread
From: Olaf Hering @ 2026-04-29 12:27 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Greg Kroah-Hartman, stable, Ky Srinivasan, linux-hyperv,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

Tue, 14 Apr 2026 13:10:08 +0200 Thorsten Blum <thorsten.blum@linux.dev>:

> Fixes: 245ba56a52a3 ("Staging: hv: Implement key/value pair (KVP)")

Please do not abuse the Fixes tag when it fact this change is "cosmetics".


Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hv: utils: handle and propagate errors in kvp_register
  2026-04-29 12:27 ` Olaf Hering
@ 2026-04-29 12:36   ` Thorsten Blum
  2026-04-29 12:44     ` Olaf Hering
  0 siblings, 1 reply; 6+ messages in thread
From: Thorsten Blum @ 2026-04-29 12:36 UTC (permalink / raw)
  To: Olaf Hering
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Greg Kroah-Hartman, stable, Ky Srinivasan, linux-hyperv,
	linux-kernel

On Wed, Apr 29, 2026 at 02:27:24PM +0200, Olaf Hering wrote:
> Tue, 14 Apr 2026 13:10:08 +0200 Thorsten Blum <thorsten.blum@linux.dev>:
> 
> > Fixes: 245ba56a52a3 ("Staging: hv: Implement key/value pair (KVP)")
> 
> Please do not abuse the Fixes tag when it fact this change is "cosmetics".

What makes you think this is just "cosmetics"?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hv: utils: handle and propagate errors in kvp_register
  2026-04-29 12:36   ` Thorsten Blum
@ 2026-04-29 12:44     ` Olaf Hering
  0 siblings, 0 replies; 6+ messages in thread
From: Olaf Hering @ 2026-04-29 12:44 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Greg Kroah-Hartman, stable, linux-hyperv, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 252 bytes --]

Wed, 29 Apr 2026 14:36:36 +0200 Thorsten Blum <thorsten.blum@linux.dev>:

> What makes you think this is just "cosmetics"?

It does fix an unlikely bug indeed, but it does not need to trigger the whole paperwork attached to a Fixes tag.


Olaf

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [EXTERNAL] [PATCH] hv: utils: handle and propagate errors in kvp_register
  2026-04-14 17:48 ` [EXTERNAL] " Long Li
@ 2026-04-29 22:15   ` Wei Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2026-04-29 22:15 UTC (permalink / raw)
  To: Long Li
  Cc: Thorsten Blum, KY Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
	Greg Kroah-Hartman, stable@vger.kernel.org, Ky Srinivasan,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org

On Tue, Apr 14, 2026 at 05:48:04PM +0000, Long Li wrote:
> > Make kvp_register() return an error code instead of silently ignoring failures, and
> > propagate the error from kvp_handle_handshake() instead of returning success.
> > 
> > This propagates both kzalloc_obj() and hvutil_transport_send() failures to
> > kvp_handle_handshake() and thus to kvp_on_msg().
> > 
> > Fixes: 245ba56a52a3 ("Staging: hv: Implement key/value pair (KVP)")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> 
> Reviewed-by:  Long Li <longli@microsoft.com>

Applied to hyperv-fixes, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-29 22:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 11:10 [PATCH] hv: utils: handle and propagate errors in kvp_register Thorsten Blum
2026-04-14 17:48 ` [EXTERNAL] " Long Li
2026-04-29 22:15   ` Wei Liu
2026-04-29 12:27 ` Olaf Hering
2026-04-29 12:36   ` Thorsten Blum
2026-04-29 12:44     ` Olaf Hering

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox