lkml.org 
[lkml]   [2015]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] misc: mic: use kstrdup() in cosm_sysfs
Date
On Sat, Oct 10 2015 at 12:14:30 PM, Joe Perches <joe@perches.com> wrote:
> On Sat, 2015-10-10 at 04:46 -0700, Geliang Tang wrote:
>> Use kstrdup instead of kmalloc and strncpy.
>
>> diff --git a/drivers/misc/mic/cosm/cosm_sysfs.c b/drivers/misc/mic/cosm/cosm_sysfs.c
> []
>> @@ -211,18 +211,14 @@ cmdline_store(struct device *dev, struct device_attribute *attr,
>> mutex_lock(&cdev->cosm_mutex);
>> kfree(cdev->cmdline);
>>
>> - cdev->cmdline = kmalloc(count + 1, GFP_KERNEL);
>> + cdev->cmdline = kstrdup(buf, GFP_KERNEL);
>>
> As count is a function argument, this isn't the same code.
>
Correct, is this code safe for unterminated strings from user land?


\
 
 \ /
  Last update: 2015-10-11 03:21    [W:0.058 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site