nfc: llcp: fix possible use of uninitialized variable in nfc_llcp_send_connect()
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Sat, 13 May 2023 11:52:04 +0000 (13:52 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 May 2023 12:03:34 +0000 (13:03 +0100)
If sock->service_name is NULL, the local variable
service_name_tlv_length will not be assigned by nfc_llcp_build_tlv(),
later leading to using value frmo the stack.  Smatch warning:

  net/nfc/llcp_commands.c:442 nfc_llcp_send_connect() error: uninitialized symbol 'service_name_tlv_length'.

Fixes: de9e5aeb4f40 ("NFC: llcp: Fix usage of llcp_add_tlv()")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/nfc/llcp_commands.c

index 41e3a20c893556fcea5403ee43779f909323b459..cdb001de069288799c99dce04294a2ebb2955b2e 100644 (file)
@@ -390,7 +390,8 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock)
        const u8 *service_name_tlv = NULL;
        const u8 *miux_tlv = NULL;
        const u8 *rw_tlv = NULL;
-       u8 service_name_tlv_length, miux_tlv_length,  rw_tlv_length, rw;
+       u8 service_name_tlv_length = 0;
+       u8 miux_tlv_length,  rw_tlv_length, rw;
        int err;
        u16 size = 0;
        __be16 miux;