gpu: ion: Replace strncpy with strlcpy

strncpy is unsafe because it does not guarantee
that the resultant string is NULL-terminated.

Replace strncpy with strlcpy and remove explicit
NULL-termination. Also correct allocation of
string buffer.

Change-Id: Id5075ef7b04f80e2bf828f52def329b926e9ec3f
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
This commit is contained in:
Olav Haugan
2012-01-24 13:50:43 -08:00
committed by Stephen Boyd
parent 5c3a35007c
commit bae1129b0c

View File

@@ -910,14 +910,13 @@ struct ion_client *ion_client_create(struct ion_device *dev,
client->handles = RB_ROOT;
mutex_init(&client->lock);
client->name = kzalloc(sizeof(name_len+1), GFP_KERNEL);
client->name = kzalloc(name_len+1, GFP_KERNEL);
if (!client->name) {
put_task_struct(current->group_leader);
kfree(client);
return ERR_PTR(-ENOMEM);
} else {
strncpy(client->name, name, name_len);
client->name[name_len] = '\0';
strlcpy(client->name, name, name_len+1);
}
client->heap_mask = heap_mask;