Tools: hv: kvp: eliminate ‘may be used uninitialized’ warning [Linux 4.9.192]

This Linux kernel change "Tools: hv: kvp: eliminate ‘may be used uninitialized’ warning" is included in the Linux 4.9.192 release. This change is authored by Vitaly Kuznetsov <vkuznets [at]> on Mon Aug 19 16:44:09 2019 +0200. The commit for this change in Linux stable tree is 6be6f81 (patch) which is from upstream commit 89eb4d8. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 89eb4d8.

Tools: hv: kvp: eliminate 'may be used uninitialized' warning

[ Upstream commit 89eb4d8d25722a0a0194cf7fa47ba602e32a6da7 ]

When building hv_kvp_daemon GCC-8.3 complains:

hv_kvp_daemon.c: In function ‘kvp_get_ip_info.constprop’:
hv_kvp_daemon.c:812:30: warning: ‘ip_buffer’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  struct hv_kvp_ipaddr_value *ip_buffer;

this seems to be a false positive: we only use ip_buffer when
op == KVP_OP_GET_IP_INFO and it is only unset when op == KVP_OP_ENUMERATE.

Silence the warning by initializing ip_buffer to NULL.

Signed-off-by: Vitaly Kuznetsov <>
Signed-off-by: Sasha Levin <>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/hv/hv_kvp_daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index fffc7c4..8340086 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -878,7 +878,7 @@ static int kvp_process_ip_address(void *addrp,
    int sn_offset = 0;
    int error = 0;
    char *buffer;
-   struct hv_kvp_ipaddr_value *ip_buffer;
+   struct hv_kvp_ipaddr_value *ip_buffer = NULL;
    char cidr_mask[5]; /* /xyz */
    int weight;
    int i;

Leave a Reply

Your email address will not be published. Required fields are marked *