diff options
Diffstat (limited to 'drivers/staging/pohmelfs/config.c')
-rw-r--r-- | drivers/staging/pohmelfs/config.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c index 9fdf2de..8c8d1c2 100644 --- a/drivers/staging/pohmelfs/config.c +++ b/drivers/staging/pohmelfs/config.c @@ -204,18 +204,18 @@ int pohmelfs_copy_crypto(struct pohmelfs_sb *psb) } if (g->hash_keysize) { - psb->hash_key = kmalloc(g->hash_keysize, GFP_KERNEL); + psb->hash_key = kmemdup(g->hash_key, g->hash_keysize, + GFP_KERNEL); if (!psb->hash_key) goto err_out_free_cipher_string; - memcpy(psb->hash_key, g->hash_key, g->hash_keysize); psb->hash_keysize = g->hash_keysize; } if (g->cipher_keysize) { - psb->cipher_key = kmalloc(g->cipher_keysize, GFP_KERNEL); + psb->cipher_key = kmemdup(g->cipher_key, g->cipher_keysize, + GFP_KERNEL); if (!psb->cipher_key) goto err_out_free_hash; - memcpy(psb->cipher_key, g->cipher_key, g->cipher_keysize); psb->cipher_keysize = g->cipher_keysize; } @@ -454,14 +454,12 @@ static int pohmelfs_crypto_hash_init(struct pohmelfs_config_group *g, struct poh g->hash_strlen = c->strlen; g->hash_keysize = c->keysize; - g->hash_key = kmalloc(c->keysize, GFP_KERNEL); + g->hash_key = kmemdup(key, c->keysize, GFP_KERNEL); if (!g->hash_key) { kfree(g->hash_string); return -ENOMEM; } - memcpy(g->hash_key, key, c->keysize); - return 0; } @@ -479,14 +477,12 @@ static int pohmelfs_crypto_cipher_init(struct pohmelfs_config_group *g, struct p g->cipher_strlen = c->strlen; g->cipher_keysize = c->keysize; - g->cipher_key = kmalloc(c->keysize, GFP_KERNEL); + g->cipher_key = kmemdup(key, c->keysize, GFP_KERNEL); if (!g->cipher_key) { kfree(g->cipher_string); return -ENOMEM; } - memcpy(g->cipher_key, key, c->keysize); - return 0; } |