diff options
| author | Li Zetao <lizetao1@huawei.com> | 2023-08-03 06:20:27 +0300 |
|---|---|---|
| committer | Hans de Goede <hdegoede@redhat.com> | 2023-08-07 14:36:20 +0300 |
| commit | 6f8972a02a6c103b67dc3a0ed9b1722943f65276 (patch) | |
| tree | 14344355b64ea8b3a91b9f0df1dbf0a0c8b85bbc | |
| parent | bfecbcb5713c6c602fae3b987478d135c46b4dc5 (diff) | |
| download | linux-6f8972a02a6c103b67dc3a0ed9b1722943f65276.tar.xz | |
platform/x86: hp-bioscfg: Use kmemdup() to replace kmalloc + memcpy
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@huawei.com>
Reviewed-by: Jorge Lopez <jorge.lopez2@hp.com>
Link: https://lore.kernel.org/r/20230803032027.3044851-1-lizetao1@huawei.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
| -rw-r--r-- | drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 11 |
1 files 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: |
