From a4469079c753ff2c3146704f1e4eec3e3e1bb30b Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Wed, 19 Sep 2018 17:09:56 -0400 Subject: Make hal_core_alloc2 a little smarter. Currently the only use of hal_core_alloc2 is to allocate two modexp cores. If the bitstream only has one, we'd allocate that one, then try to allocate it again, and spin forever. Added a check for that, and let rsa_crt fall back to trying with one modexp core if it can't find two. --- core.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core.c') diff --git a/core.c b/core.c index e170210..0905541 100644 --- a/core.c +++ b/core.c @@ -254,6 +254,13 @@ hal_error_t hal_core_alloc2(const char *name1, hal_core_t **pcore1, hal_core_lru { const int clear = pcore1 != NULL && *pcore1 == NULL; + if (name1 == name2 || strcmp(name1, name2) == 0) { + hal_core_t *core1; + if (((core1 = hal_core_find(name1, NULL)) == NULL) || + (hal_core_find(name1, core1) == NULL)) + return HAL_ERROR_CORE_NOT_FOUND; + } + for (;;) { hal_error_t err = hal_core_alloc_no_wait(name1, pcore1, pomace1); -- cgit v1.2.3