summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorHarsh Jain <harsh@chelsio.com>2017-10-08 10:07:24 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2017-11-03 14:50:46 +0100
commit396d34f9537619842b081cbe0b5ce8dbbfa00a81 (patch)
treea15ff230b27422a0365bb937db488f25fcbb8f33 /drivers/crypto
parentcrypto: chelsio - Move DMA un/mapping to chcr from lld cxgb4 driver (diff)
downloadlinux-396d34f9537619842b081cbe0b5ce8dbbfa00a81.tar.xz
linux-396d34f9537619842b081cbe0b5ce8dbbfa00a81.zip
crypto: chelsio - Fix memory leak
Fix memory leak when device does not support crypto. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Harsh Jain <harsh@chelsio.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/chelsio/chcr_core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/crypto/chelsio/chcr_core.c b/drivers/crypto/chelsio/chcr_core.c
index 32618bf0ab3b..f5a2624081dc 100644
--- a/drivers/crypto/chelsio/chcr_core.c
+++ b/drivers/crypto/chelsio/chcr_core.c
@@ -154,15 +154,15 @@ static void *chcr_uld_add(const struct cxgb4_lld_info *lld)
struct uld_ctx *u_ctx;
/* Create the device and add it in the device list */
+ if (!(lld->ulp_crypto & ULP_CRYPTO_LOOKASIDE))
+ return ERR_PTR(-EOPNOTSUPP);
+
+ /* Create the device and add it in the device list */
u_ctx = kzalloc(sizeof(*u_ctx), GFP_KERNEL);
if (!u_ctx) {
u_ctx = ERR_PTR(-ENOMEM);
goto out;
}
- if (!(lld->ulp_crypto & ULP_CRYPTO_LOOKASIDE)) {
- u_ctx = ERR_PTR(-ENOMEM);
- goto out;
- }
u_ctx->lldi = *lld;
out:
return u_ctx;