Skip to content

Commit

Permalink
mac80111: aes_gcm: clean up ieee80211_aes_gcm_key_setup_encrypt()
Browse files Browse the repository at this point in the history
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.

(Basically copied from Dan's previous patch for CCM)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Johannes Berg committed Mar 30, 2015
1 parent 45fd632 commit 07862e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/mac80211/aes_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
return tfm;

err = crypto_aead_setkey(tfm, key, key_len);
if (!err)
err = crypto_aead_setauthsize(tfm, IEEE80211_GCMP_MIC_LEN);
if (!err)
return tfm;
if (err)
goto free_aead;
err = crypto_aead_setauthsize(tfm, IEEE80211_GCMP_MIC_LEN);
if (err)
goto free_aead;

return tfm;

free_aead:
crypto_free_aead(tfm);
return ERR_PTR(err);
}
Expand Down

0 comments on commit 07862e1

Please sign in to comment.