diff options
Diffstat (limited to 'drivers/staging/pohmelfs/config.c')
-rw-r--r-- | drivers/staging/pohmelfs/config.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c index eed0e5545a55..8c8d1c282e7e 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; } @@ -238,11 +238,10 @@ static int pohmelfs_send_reply(int err, int msg_num, int action, struct cn_msg * { struct pohmelfs_cn_ack *ack; - ack = kmalloc(sizeof(struct pohmelfs_cn_ack), GFP_KERNEL); + ack = kzalloc(sizeof(struct pohmelfs_cn_ack), GFP_KERNEL); if (!ack) return -ENOMEM; - memset(ack, 0, sizeof(struct pohmelfs_cn_ack)); memcpy(&ack->msg, msg, sizeof(struct cn_msg)); if (action == POHMELFS_CTLINFO_ACK) @@ -455,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; } @@ -480,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; } @@ -509,13 +504,13 @@ static int pohmelfs_cn_crypto(struct cn_msg *msg) } switch (crypto->type) { - case POHMELFS_CRYPTO_HASH: + case POHMELFS_CRYPTO_HASH: err = pohmelfs_crypto_hash_init(g, crypto); break; - case POHMELFS_CRYPTO_CIPHER: + case POHMELFS_CRYPTO_CIPHER: err = pohmelfs_crypto_cipher_init(g, crypto); break; - default: + default: err = -ENOTSUPP; break; } @@ -536,24 +531,24 @@ static void pohmelfs_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *n return; switch (msg->flags) { - case POHMELFS_FLAGS_ADD: - case POHMELFS_FLAGS_DEL: - case POHMELFS_FLAGS_MODIFY: + case POHMELFS_FLAGS_ADD: + case POHMELFS_FLAGS_DEL: + case POHMELFS_FLAGS_MODIFY: err = pohmelfs_cn_ctl(msg, msg->flags); break; - case POHMELFS_FLAGS_FLUSH: + case POHMELFS_FLAGS_FLUSH: err = pohmelfs_cn_flush(msg); break; - case POHMELFS_FLAGS_SHOW: + case POHMELFS_FLAGS_SHOW: err = pohmelfs_cn_disp(msg); break; - case POHMELFS_FLAGS_DUMP: + case POHMELFS_FLAGS_DUMP: err = pohmelfs_cn_dump(msg); break; - case POHMELFS_FLAGS_CRYPTO: + case POHMELFS_FLAGS_CRYPTO: err = pohmelfs_cn_crypto(msg); break; - default: + default: err = -ENOSYS; break; } |