Dave Jiang <[email protected]> wrote:
> +static int nvdimm_key_instantiate(struct key *key,
> + struct key_preparsed_payload *prep)
Please use ->preparse() if you can rather than doing this in ->instantiate().
Ideally ->instantiate() should not return an error, particularly not -EINVAL
or -ENOMEM.
> +{
> + char *payload;
> +
> + payload = kzalloc(nvdimm_key_type.def_datalen, GFP_KERNEL);
> + if (!payload)
> + return -ENOMEM;
Ummm... Why not just kmemdup()? Why not use use prep->datalen here rather
than def_datalen?
> +
> + key->datalen = min(nvdimm_key_type.def_datalen, prep->datalen);
> + memcpy(payload, prep->data, key->datalen);
> + key->payload.data[0] = payload;
> + return 0;
> +}
I would recommend, firstly, that you use generic_key_instantiate() if you can;
if not, you might want to use rcu_assign_keypointer().
> + cred = prepare_kernel_cred(NULL);
> + if (!cred) {
> + rc = -ENOMEM;
> + goto failed_cred;
> + }
I wonder if you could just use &init_cred instead.
David
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm