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>
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 386593f5..5e325e9 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1044,14 +1044,13 @@
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;