Skip to content

Commit

Permalink
crypto - Avoid free() namespace collision
Browse files Browse the repository at this point in the history
gcc-10 complains about using the name of a standard library
function in the kernel, as we are not building with -ffreestanding:

crypto/xts.c:325:13: error: conflicting types for built-in function 'free'; expected 'void(void *)' [-Werror=builtin-declaration-mismatch]
  325 | static void free(struct skcipher_instance *inst)
      |             ^~~~
crypto/lrw.c:290:13: error: conflicting types for built-in function 'free'; expected 'void(void *)' [-Werror=builtin-declaration-mismatch]
  290 | static void free(struct skcipher_instance *inst)
      |             ^~~~
crypto/lrw.c:27:1: note: 'free' is declared in header '<stdlib.h>'

The xts and lrw cipher implementations run into this because they do
not use the conventional namespaced function names.

It might be better to rename all local functions in those files to
help with things like 'ctags' and 'grep', but just renaming these two
avoids the build issue. I picked the more verbose crypto_xts_free()
and crypto_lrw_free() names for consistency with several other drivers
that do use namespaced function names.

Fixes: f1c131b ("crypto: xts - Convert to skcipher")
Fixes: 700cb3f ("crypto: lrw - Convert to skcipher")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
arndb authored and herbertx committed May 8, 2020
1 parent e0664eb commit d099ea6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crypto/lrw.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
crypto_free_skcipher(ctx->child);
}

static void free(struct skcipher_instance *inst)
static void crypto_lrw_free(struct skcipher_instance *inst)
{
crypto_drop_skcipher(skcipher_instance_ctx(inst));
kfree(inst);
Expand Down Expand Up @@ -400,12 +400,12 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
inst->alg.encrypt = encrypt;
inst->alg.decrypt = decrypt;

inst->free = free;
inst->free = crypto_lrw_free;

err = skcipher_register_instance(tmpl, inst);
if (err) {
err_free_inst:
free(inst);
crypto_lrw_free(inst);
}
return err;
}
Expand Down
6 changes: 3 additions & 3 deletions crypto/xts.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
crypto_free_cipher(ctx->tweak);
}

static void free(struct skcipher_instance *inst)
static void crypto_xts_free(struct skcipher_instance *inst)
{
crypto_drop_skcipher(skcipher_instance_ctx(inst));
kfree(inst);
Expand Down Expand Up @@ -434,12 +434,12 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
inst->alg.encrypt = encrypt;
inst->alg.decrypt = decrypt;

inst->free = free;
inst->free = crypto_xts_free;

err = skcipher_register_instance(tmpl, inst);
if (err) {
err_free_inst:
free(inst);
crypto_xts_free(inst);
}
return err;
}
Expand Down

0 comments on commit d099ea6

Please sign in to comment.