Message ID | 20220825084138.1881954-2-cuigaosheng1@huawei.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Series | A few fixup patches for crypto | expand |
On Thu, Aug 25, 2022 at 04:41:37PM +0800, Gaosheng Cui wrote: > The crypto_alloc_test_larval() will return null if manager is disabled, > it may not return error pointers, so using IS_ERR_OR_NULL() > to check the return value to fix this. > > The __crypto_register_alg() will return null if manager is disabled, > it may not return error pointers, so using IS_ERR_OR_NULL() > to check the return value to fix this. > > Fixes: cad439fc040e ("crypto: api - Do not create test larvals if manager is disabled") > Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> > --- > crypto/algapi.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/crypto/algapi.c b/crypto/algapi.c > index 5c69ff8e8fa5..5a080b8aaa11 100644 > --- a/crypto/algapi.c > +++ b/crypto/algapi.c > @@ -283,7 +283,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) > } > > larval = crypto_alloc_test_larval(alg); > - if (IS_ERR(larval)) > + if (IS_ERR_OR_NULL(larval)) > goto out; A NULL indicates success, why are you jumping to the error path? Cheers,
Thanks for taking the time to review this patch. crypto_alloc_test_larval() will return null if manager is disabled, it will not return error pointers, IS_ERR should not be used to checking return value, should we fix it? or use another solution? It would be helpful if you could give some advice or fix the problem by yourself. Thanks very much! 在 2022/8/25 16:50, Herbert Xu 写道: > On Thu, Aug 25, 2022 at 04:41:37PM +0800, Gaosheng Cui wrote: >> The crypto_alloc_test_larval() will return null if manager is disabled, >> it may not return error pointers, so using IS_ERR_OR_NULL() >> to check the return value to fix this. >> >> The __crypto_register_alg() will return null if manager is disabled, >> it may not return error pointers, so using IS_ERR_OR_NULL() >> to check the return value to fix this. >> >> Fixes: cad439fc040e ("crypto: api - Do not create test larvals if manager is disabled") >> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> >> --- >> crypto/algapi.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/crypto/algapi.c b/crypto/algapi.c >> index 5c69ff8e8fa5..5a080b8aaa11 100644 >> --- a/crypto/algapi.c >> +++ b/crypto/algapi.c >> @@ -283,7 +283,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) >> } >> >> larval = crypto_alloc_test_larval(alg); >> - if (IS_ERR(larval)) >> + if (IS_ERR_OR_NULL(larval)) >> goto out; > A NULL indicates success, why are you jumping to the error path? > > Cheers,
On Thu, Aug 25, 2022 at 09:10:49PM +0800, cuigaosheng wrote: > Thanks for taking the time to review this patch. > > crypto_alloc_test_larval() will return null if manager is disabled, > it will not return error pointers, IS_ERR should not be used to checking > return value, should we fix it? or use another solution? That's because NULL is returned indicating success. When a genuine error occurs then an error pointer will be returned. IS_ERR will be true only in case of a genuine error. It will be false when either NULL or a real larval pointer is returned. You need to describe your problem more clearly as I have no idea what you're trying to fix. Cheers,
diff --git a/crypto/algapi.c b/crypto/algapi.c index 5c69ff8e8fa5..5a080b8aaa11 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -283,7 +283,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) } larval = crypto_alloc_test_larval(alg); - if (IS_ERR(larval)) + if (IS_ERR_OR_NULL(larval)) goto out; list_add(&alg->cra_list, &crypto_alg_list); @@ -651,7 +651,7 @@ int crypto_register_instance(struct crypto_template *tmpl, inst->alg.cra_flags |= (fips_internal & CRYPTO_ALG_FIPS_INTERNAL); larval = __crypto_register_alg(&inst->alg); - if (IS_ERR(larval)) + if (IS_ERR_OR_NULL(larval)) goto unlock; else if (larval) larval->test_started = true;
The crypto_alloc_test_larval() will return null if manager is disabled, it may not return error pointers, so using IS_ERR_OR_NULL() to check the return value to fix this. The __crypto_register_alg() will return null if manager is disabled, it may not return error pointers, so using IS_ERR_OR_NULL() to check the return value to fix this. Fixes: cad439fc040e ("crypto: api - Do not create test larvals if manager is disabled") Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com> --- crypto/algapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)