Disallow registration of two templates with identical names. This normally does not occur naturally but results in very confusing behaviour when it does. This is similar in spirit to commit 27016f75f5ed47e2d8e ("crypto: api - Disallow identical driver names"). Cc: Ovidiu Panait <ovidiu.panait@xxxxxxxxxxxxx> Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx> --- crypto/algapi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crypto/algapi.c b/crypto/algapi.c index e604d0d8b7b4..e11b8fdb0865 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -546,6 +546,12 @@ int crypto_register_template(struct crypto_template *tmpl) crypto_check_module_sig(tmpl->module); list_for_each_entry(q, &crypto_template_list, list) { + /* + * If we find a template already registered with the same + * name, refuse to register a new one. + */ + if (!strcmp(q->name, tmpl->name)) + goto out; if (q == tmpl) goto out; } -- 2.39.3