X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=crypto%2Fscompress.c;h=b108a30a7600140e5ed616b84431d4031fc905e4;hb=refs%2Fheads%2Faccepted%2Ftizen_unified_x;hp=24138b42a648a2fe431c410aa5696daffa5a54a7;hpb=d7b3ffe2d7e476f11d73b74093006aa936f59e8b;p=platform%2Fkernel%2Flinux-rpi.git diff --git a/crypto/scompress.c b/crypto/scompress.c index 24138b4..b108a30 100644 --- a/crypto/scompress.c +++ b/crypto/scompress.c @@ -117,6 +117,7 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) struct crypto_scomp *scomp = *tfm_ctx; void **ctx = acomp_request_ctx(req); struct scomp_scratch *scratch; + unsigned int dlen; int ret; if (!req->src || !req->slen || req->slen > SCOMP_SCRATCH_SIZE) @@ -128,6 +129,8 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) if (!req->dlen || req->dlen > SCOMP_SCRATCH_SIZE) req->dlen = SCOMP_SCRATCH_SIZE; + dlen = req->dlen; + scratch = raw_cpu_ptr(&scomp_scratch); spin_lock(&scratch->lock); @@ -145,6 +148,9 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir) ret = -ENOMEM; goto out; } + } else if (req->dlen > dlen) { + ret = -ENOSPC; + goto out; } scatterwalk_map_and_copy(scratch->dst, req->dst, 0, req->dlen, 1); @@ -240,7 +246,7 @@ static const struct crypto_type crypto_scomp_type = { #ifdef CONFIG_PROC_FS .show = crypto_scomp_show, #endif -#ifdef CONFIG_CRYPTO_USER +#if IS_ENABLED(CONFIG_CRYPTO_USER) .report = crypto_scomp_report, #endif #ifdef CONFIG_CRYPTO_STATS