summaryrefslogtreecommitdiff
path: root/net/mac80211/aes_cmac.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2021-04-09 12:40:28 +0300
committerJohannes Berg <johannes.berg@intel.com>2021-04-19 12:01:40 +0200
commit8de8570489d109d969649d67d5f49318128c1fda (patch)
tree4ed1dc01c6a0568b9b60e6f71b05e5d4ecabe80f /net/mac80211/aes_cmac.c
parentbab7f5ca81de4a2a5693a837bffe1124744028fe (diff)
mac80211: aes_cmac: check crypto_shash_setkey() return value
As crypto_shash_setkey() can fail, we should check the return value. Addresses-Coverity-ID: 1401813 ("Unchecked return value") Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Link: https://lore.kernel.org/r/iwlwifi.20210409123755.533ff7acf1d2.I034bafa201c4a6823333f8410aeaa60cca5ee9e0@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/aes_cmac.c')
-rw-r--r--net/mac80211/aes_cmac.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/net/mac80211/aes_cmac.c b/net/mac80211/aes_cmac.c
index b31f1021ad9c..48c04f89de20 100644
--- a/net/mac80211/aes_cmac.c
+++ b/net/mac80211/aes_cmac.c
@@ -2,6 +2,7 @@
/*
* AES-128-CMAC with TLen 16 for IEEE 802.11w BIP
* Copyright 2008, Jouni Malinen <j@w1.fi>
+ * Copyright (C) 2020 Intel Corporation
*/
#include <linux/kernel.h>
@@ -73,8 +74,14 @@ struct crypto_shash *ieee80211_aes_cmac_key_setup(const u8 key[],
struct crypto_shash *tfm;
tfm = crypto_alloc_shash("cmac(aes)", 0, 0);
- if (!IS_ERR(tfm))
- crypto_shash_setkey(tfm, key, key_len);
+ if (!IS_ERR(tfm)) {
+ int err = crypto_shash_setkey(tfm, key, key_len);
+
+ if (err) {
+ crypto_free_shash(tfm);
+ return ERR_PTR(err);
+ }
+ }
return tfm;
}