Skip to content

Commit d099ea6

Browse files
arndbherbertx
authored andcommitted
crypto - Avoid free() namespace collision
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>
1 parent e0664eb commit d099ea6

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎crypto/lrw.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
287287
crypto_free_skcipher(ctx->child);
288288
}
289289

290-
static void free(struct skcipher_instance *inst)
290+
static void crypto_lrw_free(struct skcipher_instance *inst)
291291
{
292292
crypto_drop_skcipher(skcipher_instance_ctx(inst));
293293
kfree(inst);
@@ -400,12 +400,12 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
400400
inst->alg.encrypt = encrypt;
401401
inst->alg.decrypt = decrypt;
402402

403-
inst->free = free;
403+
inst->free = crypto_lrw_free;
404404

405405
err = skcipher_register_instance(tmpl, inst);
406406
if (err) {
407407
err_free_inst:
408-
free(inst);
408+
crypto_lrw_free(inst);
409409
}
410410
return err;
411411
}

‎crypto/xts.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static void exit_tfm(struct crypto_skcipher *tfm)
322322
crypto_free_cipher(ctx->tweak);
323323
}
324324

325-
static void free(struct skcipher_instance *inst)
325+
static void crypto_xts_free(struct skcipher_instance *inst)
326326
{
327327
crypto_drop_skcipher(skcipher_instance_ctx(inst));
328328
kfree(inst);
@@ -434,12 +434,12 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb)
434434
inst->alg.encrypt = encrypt;
435435
inst->alg.decrypt = decrypt;
436436

437-
inst->free = free;
437+
inst->free = crypto_xts_free;
438438

439439
err = skcipher_register_instance(tmpl, inst);
440440
if (err) {
441441
err_free_inst:
442-
free(inst);
442+
crypto_xts_free(inst);
443443
}
444444
return err;
445445
}

0 commit comments

Comments
 (0)