mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 13:51:00 +00:00
hv: utils: handle and propagate errors in kvp_register
[ Upstream commit 3fcf923302a8f5c0dc3af3d2ca2657cb5fae4297 ]
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: 245ba56a52 ("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>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
44f14f74a6
commit
d14eb26f87
@ -92,7 +92,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);
|
||||
@ -126,24 +126,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(sizeof(*kvp_msg), GFP_KERNEL);
|
||||
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)
|
||||
@ -185,9 +187,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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user