Skip to contentSkip to conversation

tipc: fix update of the uninitialized variable err

PATCH Applied Colin King 2 participants 2 messages Nov 11, 2019 – Nov 12, 2019

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 tipc: fix update of the uninitialized variable err

From: Colin Ian King <[email protected]>

Variable err is not uninitialized and hence can potentially contain any garbage value. This may cause an error when logical or'ing the return values from the calls to functions crypto_aead_setauthsize or crypto_aead_setkey. Fix this by setting err to the return of crypto_aead_setauthsize rather than or'ing in the return into the uninitialized variable

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
---
 net/tipc/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/crypto.c +1 -1
index 05f7ca76e8ce..990a872cec46 100644
@@ -463,7 +463,7 @@ static int tipc_aead_init(struct tipc_aead **aead, struct tipc_aead_key *ukey,
 			break;
 		}
 
-		err |= crypto_aead_setauthsize(tfm, TIPC_AES_GCM_TAG_SIZE);
+		err = crypto_aead_setauthsize(tfm, TIPC_AES_GCM_TAG_SIZE);
 		err |= crypto_aead_setkey(tfm, ukey->key, keylen);
 		if (unlikely(err)) {
 			crypto_free_aead(tfm);
Signature · 1 line
2.20.1
Applied
#1 lore raw

From: Colin King <[email protected]>
Date: Mon, 11 Nov 2019 12:33:34 +0000

Quoted 9 lines

From: Colin Ian King <[email protected]>

Variable err is not uninitialized and hence can potentially contain any garbage value. This may cause an error when logical or'ing the return values from the calls to functions crypto_aead_setauthsize or crypto_aead_setkey. Fix this by setting err to the return of crypto_aead_setauthsize rather than or'ing in the return into the uninitialized variable

Quoted 3 lines

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")

Applied.