From 34f84c584556c2342274330fa2ce15de9ff315bd Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Thu, 15 Oct 2020 07:07:41 -0400 Subject: [PATCH] lib/sock: zero out sock_impl opts By design the opts for each implementation can not match spdk_sock_impl_opts. During get_opts for specific implementation only used fields are filled. Yet iterating over all spdk_sock_impl_opts fields would yeild garbage values for unset fields. This is the case right now when doing save_config RPC with uring enabled. A garbe value for enable_zerocopy_send is returned. sock.c:829:62: runtime error: load of value 165, which is not a valid value for type '_Bool' Signed-off-by: Tomasz Zawadzki Change-Id: Ie0512a7dffc36c8ff89256d08f8a2f4fefcf9e83 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4699 Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk --- module/sock/posix/posix.c | 1 + module/sock/uring/uring.c | 1 + 2 files changed, 2 insertions(+) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index 18467cd0e..534a61b54 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -1344,6 +1344,7 @@ posix_sock_impl_get_opts(struct spdk_sock_impl_opts *opts, size_t *len) errno = EINVAL; return -1; } + memset(opts, 0, *len); #define FIELD_OK(field) \ offsetof(struct spdk_sock_impl_opts, field) + sizeof(opts->field) <= *len diff --git a/module/sock/uring/uring.c b/module/sock/uring/uring.c index 447cccc9f..0386f757b 100644 --- a/module/sock/uring/uring.c +++ b/module/sock/uring/uring.c @@ -1317,6 +1317,7 @@ uring_sock_impl_get_opts(struct spdk_sock_impl_opts *opts, size_t *len) errno = EINVAL; return -1; } + memset(opts, 0, *len); #define FIELD_OK(field) \ offsetof(struct spdk_sock_impl_opts, field) + sizeof(opts->field) <= *len