From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au,
giovanni.cabiddu@intel.com
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v2 2/3] crypto: scompress - free partially allocated scratch buffers on failure
Date: Fri, 21 Jul 2017 16:42:37 +0100 [thread overview]
Message-ID: <20170721154238.21697-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20170721154238.21697-1-ard.biesheuvel@linaro.org>
When allocating the per-CPU scratch buffers, we allocate the source
and destination buffers separately, but bail immediately if the second
allocation fails, without freeing the first one. Fix that.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
crypto/scompress.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crypto/scompress.c b/crypto/scompress.c
index 0b40d991d65f..2c07648305ad 100644
--- a/crypto/scompress.c
+++ b/crypto/scompress.c
@@ -125,8 +125,11 @@ static int crypto_scomp_alloc_all_scratches(void)
if (!scomp_src_scratches)
return -ENOMEM;
scomp_dst_scratches = crypto_scomp_alloc_scratches();
- if (!scomp_dst_scratches)
+ if (!scomp_dst_scratches) {
+ crypto_scomp_free_scratches(scomp_src_scratches);
+ scomp_src_scratches = NULL;
return -ENOMEM;
+ }
}
return 0;
}
--
2.11.0
next prev parent reply other threads:[~2017-07-21 15:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-21 15:42 [PATCH v2 0/3] crypto: scompress - defer allocation of percpu scratch buffers Ard Biesheuvel
2017-07-21 15:42 ` [PATCH v2 1/3] crypto: scompress - don't sleep with preemption disabled Ard Biesheuvel
2017-07-21 15:42 ` Ard Biesheuvel [this message]
2017-07-21 15:42 ` [PATCH v2 3/3] crypto: scompress - defer allocation of scratch buffer to first use Ard Biesheuvel
2017-07-25 23:36 ` Giovanni Cabiddu
2017-07-26 0:07 ` Ard Biesheuvel
2017-07-28 9:13 ` Giovanni Cabiddu
2017-08-03 6:24 ` [PATCH v2 0/3] crypto: scompress - defer allocation of percpu scratch buffers Herbert Xu
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=20170721154238.21697-3-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=giovanni.cabiddu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@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).