diff options
| author | Wei Yongjun <weiyj.lk@gmail.com> | 2016-08-20 11:06:51 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-08-24 09:04:49 -0400 |
| commit | 1a45d7e343251e5396d353c1ae6ab1cebead9766 (patch) | |
| tree | f9edd012502353540c2e00f997aa55ca570dc482 /crypto | |
| parent | b46b9d1aadf7f31eb5c0bab20cd61e71011156cf (diff) | |
crypto: drbg - fix error return code
Fix to return a negative error code from the error handling
case instead of 0.
Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
Acked-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/drbg.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c index edf3ce04e87f..fb33f7d3b052 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c | |||
| @@ -1178,12 +1178,16 @@ static inline int drbg_alloc_state(struct drbg_state *drbg) | |||
| 1178 | goto err; | 1178 | goto err; |
| 1179 | 1179 | ||
| 1180 | drbg->Vbuf = kmalloc(drbg_statelen(drbg) + ret, GFP_KERNEL); | 1180 | drbg->Vbuf = kmalloc(drbg_statelen(drbg) + ret, GFP_KERNEL); |
| 1181 | if (!drbg->Vbuf) | 1181 | if (!drbg->Vbuf) { |
| 1182 | ret = -ENOMEM; | ||
| 1182 | goto fini; | 1183 | goto fini; |
| 1184 | } | ||
| 1183 | drbg->V = PTR_ALIGN(drbg->Vbuf, ret + 1); | 1185 | drbg->V = PTR_ALIGN(drbg->Vbuf, ret + 1); |
| 1184 | drbg->Cbuf = kmalloc(drbg_statelen(drbg) + ret, GFP_KERNEL); | 1186 | drbg->Cbuf = kmalloc(drbg_statelen(drbg) + ret, GFP_KERNEL); |
| 1185 | if (!drbg->Cbuf) | 1187 | if (!drbg->Cbuf) { |
| 1188 | ret = -ENOMEM; | ||
| 1186 | goto fini; | 1189 | goto fini; |
| 1190 | } | ||
| 1187 | drbg->C = PTR_ALIGN(drbg->Cbuf, ret + 1); | 1191 | drbg->C = PTR_ALIGN(drbg->Cbuf, ret + 1); |
| 1188 | /* scratchpad is only generated for CTR and Hash */ | 1192 | /* scratchpad is only generated for CTR and Hash */ |
| 1189 | if (drbg->core->flags & DRBG_HMAC) | 1193 | if (drbg->core->flags & DRBG_HMAC) |
| @@ -1199,8 +1203,10 @@ static inline int drbg_alloc_state(struct drbg_state *drbg) | |||
| 1199 | 1203 | ||
| 1200 | if (0 < sb_size) { | 1204 | if (0 < sb_size) { |
| 1201 | drbg->scratchpadbuf = kzalloc(sb_size + ret, GFP_KERNEL); | 1205 | drbg->scratchpadbuf = kzalloc(sb_size + ret, GFP_KERNEL); |
| 1202 | if (!drbg->scratchpadbuf) | 1206 | if (!drbg->scratchpadbuf) { |
| 1207 | ret = -ENOMEM; | ||
| 1203 | goto fini; | 1208 | goto fini; |
| 1209 | } | ||
| 1204 | drbg->scratchpad = PTR_ALIGN(drbg->scratchpadbuf, ret + 1); | 1210 | drbg->scratchpad = PTR_ALIGN(drbg->scratchpadbuf, ret + 1); |
| 1205 | } | 1211 | } |
| 1206 | 1212 | ||
| @@ -1999,7 +2005,7 @@ static int __init drbg_init(void) | |||
| 1999 | { | 2005 | { |
| 2000 | unsigned int i = 0; /* pointer to drbg_algs */ | 2006 | unsigned int i = 0; /* pointer to drbg_algs */ |
| 2001 | unsigned int j = 0; /* pointer to drbg_cores */ | 2007 | unsigned int j = 0; /* pointer to drbg_cores */ |
| 2002 | int ret = -EFAULT; | 2008 | int ret; |
| 2003 | 2009 | ||
| 2004 | ret = drbg_healthcheck_sanity(); | 2010 | ret = drbg_healthcheck_sanity(); |
| 2005 | if (ret) | 2011 | if (ret) |
| @@ -2009,7 +2015,7 @@ static int __init drbg_init(void) | |||
| 2009 | pr_info("DRBG: Cannot register all DRBG types" | 2015 | pr_info("DRBG: Cannot register all DRBG types" |
| 2010 | "(slots needed: %zu, slots available: %zu)\n", | 2016 | "(slots needed: %zu, slots available: %zu)\n", |
| 2011 | ARRAY_SIZE(drbg_cores) * 2, ARRAY_SIZE(drbg_algs)); | 2017 | ARRAY_SIZE(drbg_cores) * 2, ARRAY_SIZE(drbg_algs)); |
| 2012 | return ret; | 2018 | return -EFAULT; |
| 2013 | } | 2019 | } |
| 2014 | 2020 | ||
| 2015 | /* | 2021 | /* |
