summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2015-03-23 17:08:14 +0300
committerJohannes Berg <johannes.berg@intel.com>2015-03-30 10:40:03 +0200
commit45fd63293a214c48d6d3856bb39cf207a805dfda (patch)
tree95ac3231e1712190dfc607114546093827046f65 /net
parent82ca6ef686f0fcefe2c1ad4ab74d5caf41be03a9 (diff)
downloadblackbird-op-linux-45fd63293a214c48d6d3856bb39cf207a805dfda.tar.gz
blackbird-op-linux-45fd63293a214c48d6d3856bb39cf207a805dfda.zip
mac80111: aes_ccm: cleanup ieee80211_aes_key_setup_encrypt()
This code is written using an anti-pattern called "success handling" which makes it hard to read, especially if you are used to normal kernel style. It should instead be written as a list of directives in a row with branches for error handling. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/aes_ccm.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
index 7869bb40acaa..208df7c0b6ea 100644
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
@@ -85,11 +85,15 @@ struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
return tfm;
err = crypto_aead_setkey(tfm, key, key_len);
- if (!err)
- err = crypto_aead_setauthsize(tfm, mic_len);
- if (!err)
- return tfm;
+ if (err)
+ goto free_aead;
+ err = crypto_aead_setauthsize(tfm, mic_len);
+ if (err)
+ goto free_aead;
+
+ return tfm;
+free_aead:
crypto_free_aead(tfm);
return ERR_PTR(err);
}
OpenPOWER on IntegriCloud