From: Dan Carpenter <dan.carpenter@oracle.com>
To: jouni@qca.qualcomm.com
Cc: linux-wireless@vger.kernel.org
Subject: re: mac80111: Add BIP-GMAC-128 and BIP-GMAC-256 ciphers
Date: Thu, 19 Mar 2015 15:53:14 +0300 [thread overview]
Message-ID: <20150319125314.GA15250@mwanda> (raw)
Hello Jouni Malinen,
The patch 8ade538bf39b: "mac80111: Add BIP-GMAC-128 and BIP-GMAC-256
ciphers" from Jan 24, 2015, leads to the following static checker
warning:
net/mac80211/aes_gmac.c:74 ieee80211_aes_gmac_key_setup()
warn: we tested 'err' before and it was 'true'
net/mac80211/aes_gmac.c
61 struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[],
62 size_t key_len)
63 {
64 struct crypto_aead *tfm;
65 int err;
66
67 tfm = crypto_alloc_aead("gcm(aes)", 0, CRYPTO_ALG_ASYNC);
68 if (IS_ERR(tfm))
69 return tfm;
70
71 err = crypto_aead_setkey(tfm, key, key_len);
72 if (!err)
^^^^
This is success handling. In the kernel, everyone expects error
hanlding like "if (err) " so this makes the code hard to read if you
have a job and need to read code quickly. At first I missed the "!"
character, and then I thought, "What?? Is err a pointer?"
73 return tfm;
74 if (!err)
75 err = crypto_aead_setauthsize(tfm, GMAC_MIC_LEN);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is dead code.
76
77 crypto_free_aead(tfm);
78 return ERR_PTR(err);
This function should be a list of commands in a row with tiny detours
for exceptions and error handling. It messes everyone up if the success
path is hidden somewhere in the middle and it leads to bugs like this.
79 }
regards,
dan carpenter
next reply other threads:[~2015-03-19 12:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 12:53 Dan Carpenter [this message]
2015-03-23 13:24 ` mac80111: Add BIP-GMAC-128 and BIP-GMAC-256 ciphers Jouni Malinen
2015-03-23 14:08 ` [patch] mac80111: aes_ccm: cleanup ieee80211_aes_key_setup_encrypt() Dan Carpenter
2015-03-24 9:32 ` Ard Biesheuvel
2015-03-30 8:40 ` Johannes Berg
2015-03-23 14:40 ` mac80111: Add BIP-GMAC-128 and BIP-GMAC-256 ciphers Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150319125314.GA15250@mwanda \
--to=dan.carpenter@oracle.com \
--cc=jouni@qca.qualcomm.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).