linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] tipc: fix update of the uninitialized variable err
@ 2019-11-11 12:33 Colin King
  2019-11-12  6:05 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-11-11 12:33 UTC (permalink / raw)
  To: Jon Maloy, Ying Xue, David S . Miller, Tuong Lien, netdev,
	tipc-discussion
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/tipc/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index 05f7ca76e8ce..990a872cec46 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] tipc: fix update of the uninitialized variable err
  2019-11-11 12:33 [PATCH][next] tipc: fix update of the uninitialized variable err Colin King
@ 2019-11-12  6:05 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-11-12  6:05 UTC (permalink / raw)
  To: colin.king
  Cc: jon.maloy, ying.xue, tuong.t.lien, netdev, tipc-discussion,
	kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Mon, 11 Nov 2019 12:33:34 +0000

> From: Colin Ian King <colin.king@canonical.com>
> 
> 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")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-12 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 12:33 [PATCH][next] tipc: fix update of the uninitialized variable err Colin King
2019-11-12  6:05 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).