From: Jesper Juhl <juhl-lkml@dif.dk>
To: "David S. Miller" <davem@davemloft.net>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
James Morris <jmorris@intercode.com.au>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] crypto: resource release functions ought to check for NULL (crypto_free_tfm)
Date: Fri, 15 Apr 2005 01:15:58 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.62.0504150106420.3466@dragon.hyggekrogen.localhost> (raw)
As far as I'm aware there's a general concensus that functions that are
responsible for freeing resources should be able to cope with being passed
a NULL pointer. This makes sense as it removes the need for all callers to
check for NULL, thus elliminating the bugs that happen when some forget
(safer to just check centrally in the freeing function) and it also makes
for smaller code all over due to the lack of all those NULL checks.
This patch makes it safe to pass the crypto_free_tfm() function a NULL
pointer. Once this patch is applied we can start removing the NULL checks
from the callers.
Please consider applying.
Please CC: me on replies as I'm not subscribed to linux-crypto
Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---
api.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
--- linux-2.6.12-rc2-mm3-orig/crypto/api.c 2005-04-11 21:20:39.000000000 +0200
+++ linux-2.6.12-rc2-mm3/crypto/api.c 2005-04-15 01:05:52.000000000 +0200
@@ -163,8 +163,14 @@ out:
void crypto_free_tfm(struct crypto_tfm *tfm)
{
- struct crypto_alg *alg = tfm->__crt_alg;
- int size = sizeof(*tfm) + alg->cra_ctxsize;
+ struct crypto_alg *alg;
+ int size;
+
+ if (!tfm)
+ return;
+
+ alg = tfm->__crt_alg;
+ size = sizeof(*tfm) + alg->cra_ctxsize;
crypto_exit_ops(tfm);
crypto_alg_put(alg);
--
Jesper Juhl
PS. Please CC: me on replies to linux-crypto as I'm not subscribed to that
list.
next reply other threads:[~2005-04-14 23:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-14 23:15 Jesper Juhl [this message]
2005-04-18 11:49 ` Herbert Xu
2005-04-18 15:23 ` Jesper Juhl
2005-04-19 8:20 ` Herbert Xu
2005-04-19 8:39 ` Jesper Juhl
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=Pine.LNX.4.62.0504150106420.3466@dragon.hyggekrogen.localhost \
--to=juhl-lkml@dif.dk \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jmorris@intercode.com.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®