Skip to content

Commit

Permalink
crypto: iaa - Use kmemdup() instead of kzalloc() and memcpy()
Browse files Browse the repository at this point in the history
Fixes the following two Coccinelle/coccicheck warnings reported by
memdup.cocci:

	iaa_crypto_main.c:350:19-26: WARNING opportunity for kmemdup
	iaa_crypto_main.c:358:18-25: WARNING opportunity for kmemdup

Signed-off-by: Thorsten Blum <[email protected]>
Reviewed-by: Tom Zanussi <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
toblux authored and herbertx committed May 10, 2024
1 parent e02ea6f commit bfbe27b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/crypto/intel/iaa/iaa_crypto_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,16 @@ int add_iaa_compression_mode(const char *name,
goto free;

if (ll_table) {
mode->ll_table = kzalloc(ll_table_size, GFP_KERNEL);
mode->ll_table = kmemdup(ll_table, ll_table_size, GFP_KERNEL);
if (!mode->ll_table)
goto free;
memcpy(mode->ll_table, ll_table, ll_table_size);
mode->ll_table_size = ll_table_size;
}

if (d_table) {
mode->d_table = kzalloc(d_table_size, GFP_KERNEL);
mode->d_table = kmemdup(d_table, d_table_size, GFP_KERNEL);
if (!mode->d_table)
goto free;
memcpy(mode->d_table, d_table, d_table_size);
mode->d_table_size = d_table_size;
}

Expand Down

0 comments on commit bfbe27b

Please sign in to comment.