lkml.org 
[lkml]   [2013]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drivers: char: ipmi: Replaced kmalloc and strcpy with kstrdup
On 03/16/2013 09:16 AM, Alexandru Gheorghiu wrote:
> Replaced calls to kmalloc followed by strcpy with a sincle call to kstrdup.
> Patch found using coccinelle.
>
> Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
> ---
> drivers/char/ipmi/ipmi_msghandler.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 053201b..617b443 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -2037,12 +2037,11 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
> entry = kmalloc(sizeof(*entry), GFP_KERNEL);
> if (!entry)
> return -ENOMEM;
> - entry->name = kmalloc(strlen(name)+1, GFP_KERNEL);
> + entry->name = kstrdup(name, GFP_KERNEL);
> if (!entry->name) {
> kfree(entry);
> return -ENOMEM;
> }
> - strcpy(entry->name, name);
>
> file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data);
> if (!file) {
Actually, I should say that I've pulled this into my tree.

Thanks,

-corey


\
 
 \ /
  Last update: 2013-03-18 16:01    [W:0.036 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site