Hi, On 8/3/23 05:20, Li Zetao wrote: > There are some warnings reported by coccinelle: > > ./drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c:317:35-42: > WARNING opportunity for kmemdup > ./drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c:270:40-47: > WARNING opportunity for kmemdup > ./drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c:233:36-43: > WARNING opportunity for kmemdup > > Use kmemdup rather than duplicating its implementation. > > Signed-off-by: Li Zetao <lizetao1@xxxxxxxxxx> Thank you for your patch, I've applied this patch to my review-hans branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while. Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window. Regards, Hans > --- > .../platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c > index 02291e32684f..86f90238750c 100644 > --- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c > +++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c > @@ -230,12 +230,10 @@ static ssize_t sk_store(struct kobject *kobj, > length--; > > /* allocate space and copy current signing key */ > - bioscfg_drv.spm_data.signing_key = kmalloc(length, GFP_KERNEL); > + bioscfg_drv.spm_data.signing_key = kmemdup(buf, length, GFP_KERNEL); > if (!bioscfg_drv.spm_data.signing_key) > return -ENOMEM; > > - memcpy(bioscfg_drv.spm_data.signing_key, buf, length); > - > /* submit signing key payload */ > ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_SK, > HPWMI_SECUREPLATFORM, > @@ -267,14 +265,12 @@ static ssize_t kek_store(struct kobject *kobj, > length--; > > /* allocate space and copy current signing key */ > - bioscfg_drv.spm_data.endorsement_key = kmalloc(length, GFP_KERNEL); > + bioscfg_drv.spm_data.endorsement_key = kmemdup(buf, length, GFP_KERNEL); > if (!bioscfg_drv.spm_data.endorsement_key) { > ret = -ENOMEM; > goto exit_kek; > } > > - memcpy(bioscfg_drv.spm_data.endorsement_key, buf, length); > - > ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_KEK, > HPWMI_SECUREPLATFORM, > (void *)bioscfg_drv.spm_data.endorsement_key, > @@ -314,13 +310,12 @@ static ssize_t auth_token_store(struct kobject *kobj, > length--; > > /* allocate space and copy current auth token */ > - bioscfg_drv.spm_data.auth_token = kmalloc(length, GFP_KERNEL); > + bioscfg_drv.spm_data.auth_token = kmemdup(buf, length, GFP_KERNEL); > if (!bioscfg_drv.spm_data.auth_token) { > ret = -ENOMEM; > goto exit_token; > } > > - memcpy(bioscfg_drv.spm_data.auth_token, buf, length); > return count; > > exit_token: