lkml.org 
[lkml]   [2023]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH v3 2/3] nvme-auth: use transformed key size to create resp
    > +struct nvme_dhchap_key *nvme_auth_transform_key(struct nvme_dhchap_key *key, char *nqn)

    Please avoid the overly long line.

    > + key_len = sizeof(*key) + key->len;

    struct_size again. And maybe add a helper to calculate the size for
    a key instea dof duplicating it.

    > + transformed_key = kmemdup(key, key_len, GFP_KERNEL);
    > return transformed_key ? transformed_key : ERR_PTR(-ENOMEM);

    Nit, but I find the ? : syntax very confusing when not used in things
    like macros or argument lines. A

    if (!transformed_key)
    return ERR_PTR(-ENOMEM);
    return transformed_key;

    is a bit longer, but much easier to read.

    > }
    > hmac_name = nvme_auth_hmac_name(key->hash);
    > @@ -257,7 +258,7 @@ u8 *nvme_auth_transform_key(struct nvme_dhchap_key *key, char *nqn)
    >
    > key_tfm = crypto_alloc_shash(hmac_name, 0, 0);
    > if (IS_ERR(key_tfm))
    > - return (u8 *)key_tfm;
    > + return (void *)key_tfm;

    This should (already in the original code) use ERR_CAST instead.

    > + transformed_key = nvme_auth_transform_key(ctrl->host_key, ctrl->hostnqn);

    Please avoid the overly long line here as well.

    > +struct nvme_dhchap_key *nvme_auth_transform_key(struct nvme_dhchap_key *key, char *nqn);

    ... and here.

    \
     
     \ /
      Last update: 2023-10-17 08:13    [W:8.306 / U:1.208 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site