2013-06-01 09:40:16

by Thomas Meyer

[permalink] [raw]
Subject: [PATCH] efi, pstore: Cocci spatch "memdup.spatch"


Signed-off-by: Thomas Meyer <[email protected]>
---

diff -u -p a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -79,10 +79,9 @@ static int efi_pstore_read_func(struct e
&entry->var.DataSize, entry->var.Data);
size = entry->var.DataSize;

- *cb_data->buf = kmalloc(size, GFP_KERNEL);
+ *cb_data->buf = kmemdup(entry->var.Data, size, GFP_KERNEL);
if (*cb_data->buf == NULL)
return -ENOMEM;
- memcpy(*cb_data->buf, entry->var.Data, size);
return size;
}




2013-06-01 17:11:40

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] efi, pstore: Cocci spatch "memdup.spatch"

On Sat, Jun 1, 2013 at 2:40 AM, Thomas Meyer <[email protected]> wrote:
>
> Signed-off-by: Thomas Meyer <[email protected]>

Acked-by: Kees Cook <[email protected]>

Thanks!

-Kees

> ---
>
> diff -u -p a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
> --- a/drivers/firmware/efi/efi-pstore.c
> +++ b/drivers/firmware/efi/efi-pstore.c
> @@ -79,10 +79,9 @@ static int efi_pstore_read_func(struct e
> &entry->var.DataSize, entry->var.Data);
> size = entry->var.DataSize;
>
> - *cb_data->buf = kmalloc(size, GFP_KERNEL);
> + *cb_data->buf = kmemdup(entry->var.Data, size, GFP_KERNEL);
> if (*cb_data->buf == NULL)
> return -ENOMEM;
> - memcpy(*cb_data->buf, entry->var.Data, size);
> return size;
> }
>
>
>
>



--
Kees Cook
Chrome OS Security

2013-06-03 10:18:04

by Matt Fleming

[permalink] [raw]
Subject: Re: [PATCH] efi, pstore: Cocci spatch "memdup.spatch"

On Sat, 01 Jun, at 11:40:02AM, Thomas Meyer wrote:
>
> Signed-off-by: Thomas Meyer <[email protected]>
> ---
>
> diff -u -p a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
> --- a/drivers/firmware/efi/efi-pstore.c
> +++ b/drivers/firmware/efi/efi-pstore.c
> @@ -79,10 +79,9 @@ static int efi_pstore_read_func(struct e
> &entry->var.DataSize, entry->var.Data);
> size = entry->var.DataSize;
>
> - *cb_data->buf = kmalloc(size, GFP_KERNEL);
> + *cb_data->buf = kmemdup(entry->var.Data, size, GFP_KERNEL);
> if (*cb_data->buf == NULL)
> return -ENOMEM;
> - memcpy(*cb_data->buf, entry->var.Data, size);
> return size;
> }

Who wants to pick this one up? Tony?

--
Matt Fleming, Intel Open Source Technology Center

2013-06-03 17:19:44

by Luck, Tony

[permalink] [raw]
Subject: RE: [PATCH] efi, pstore: Cocci spatch "memdup.spatch"

> Who wants to pick this one up? Tony?

Sure - I'll take it.

-Tony