2018-05-09 00:14:01

by Ji-Hun Kim

[permalink] [raw]
Subject: [PATCH 1/2] tpm: replace kmalloc() + memcpy() with kmemdup()

Use kmemdup rather than duplicating its implementation.

Signed-off-by: Ji-Hun Kim <[email protected]>
---
drivers/char/tpm/eventlog/of.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/tpm/eventlog/of.c b/drivers/char/tpm/eventlog/of.c
index b7cac47..bba5fba 100644
--- a/drivers/char/tpm/eventlog/of.c
+++ b/drivers/char/tpm/eventlog/of.c
@@ -69,14 +69,12 @@ int tpm_read_log_of(struct tpm_chip *chip)
return -EIO;
}

- log->bios_event_log = kmalloc(size, GFP_KERNEL);
+ log->bios_event_log = kmemdup(__va(base), size, GFP_KERNEL);
if (!log->bios_event_log)
return -ENOMEM;

log->bios_event_log_end = log->bios_event_log + size;

- memcpy(log->bios_event_log, __va(base), size);
-
if (chip->flags & TPM_CHIP_FLAG_TPM2)
return EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
return EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
--
1.9.1



2018-05-09 00:14:01

by Ji-Hun Kim

[permalink] [raw]
Subject: [PATCH 2/2] tpm: replace kmalloc() + memcpy() with kmemdup()

Use kmemdup rather than duplicating its implementation.

Signed-off-by: Ji-Hun Kim <[email protected]>
---
drivers/char/tpm/eventlog/efi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/char/tpm/eventlog/efi.c b/drivers/char/tpm/eventlog/efi.c
index 68f1e7e..3e673ab 100644
--- a/drivers/char/tpm/eventlog/efi.c
+++ b/drivers/char/tpm/eventlog/efi.c
@@ -51,10 +51,9 @@ int tpm_read_log_efi(struct tpm_chip *chip)
}

/* malloc EventLog space */
- log->bios_event_log = kmalloc(log_size, GFP_KERNEL);
+ log->bios_event_log = kmemdup(log_tbl->log, log_size, GFP_KERNEL);
if (!log->bios_event_log)
goto err_memunmap;
- memcpy(log->bios_event_log, log_tbl->log, log_size);
log->bios_event_log_end = log->bios_event_log + log_size;

tpm_log_version = log_tbl->version;
--
1.9.1


2018-05-09 19:17:45

by James Morris

[permalink] [raw]
Subject: Re: [PATCH 1/2] tpm: replace kmalloc() + memcpy() with kmemdup()

On Wed, 9 May 2018, Ji-Hun Kim wrote:

> Use kmemdup rather than duplicating its implementation.
>
> Signed-off-by: Ji-Hun Kim <[email protected]>


Reviewed-by: James Morris <[email protected]>


--
James Morris
<[email protected]>


2018-05-09 19:18:00

by James Morris

[permalink] [raw]
Subject: Re: [PATCH 2/2] tpm: replace kmalloc() + memcpy() with kmemdup()

On Wed, 9 May 2018, Ji-Hun Kim wrote:

> Use kmemdup rather than duplicating its implementation.
>
> Signed-off-by: Ji-Hun Kim <[email protected]>


Reviewed-by: James Morris <[email protected]>


--
James Morris
<[email protected]>


2018-05-14 10:59:03

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH 1/2] tpm: replace kmalloc() + memcpy() with kmemdup()

On Wed, May 09, 2018 at 09:12:36AM +0900, Ji-Hun Kim wrote:
> Use kmemdup rather than duplicating its implementation.
>
> Signed-off-by: Ji-Hun Kim <[email protected]>

Reviewed-by: Jarkko Sakkinen <[email protected]>

/Jarkko

2018-05-14 10:59:29

by Jarkko Sakkinen

[permalink] [raw]
Subject: Re: [PATCH 2/2] tpm: replace kmalloc() + memcpy() with kmemdup()

On Wed, May 09, 2018 at 09:12:37AM +0900, Ji-Hun Kim wrote:
> Use kmemdup rather than duplicating its implementation.
>
> Signed-off-by: Ji-Hun Kim <[email protected]>

Reviewed-by: Jarkko Sakkinen <[email protected]>

/Jarkko