Skip to content

Commit

Permalink
mac80211: aes_cmac: check crypto_shash_setkey() return value
Browse files Browse the repository at this point in the history
As crypto_shash_setkey() can fail, we should check the return value.

Addresses-Coverity-ID: 1401813 ("Unchecked return value")
Signed-off-by: Johannes Berg <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
Link: https://lore.kernel.org/r/iwlwifi.20210409123755.533ff7acf1d2.I034bafa201c4a6823333f8410aeaa60cca5ee9e0@changeid
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
jmberg-intel committed Apr 19, 2021
1 parent bab7f5c commit 8de8570
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions net/mac80211/aes_cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/*
* AES-128-CMAC with TLen 16 for IEEE 802.11w BIP
* Copyright 2008, Jouni Malinen <[email protected]>
* Copyright (C) 2020 Intel Corporation
*/

#include <linux/kernel.h>
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8de8570

Please sign in to comment.