lkml.org 
[lkml]   [2022]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 11/36] tty/vt: consolemap: zero uni_pgdir using kcalloc()
Date
The newly allocated p->uni_pgdir[n] is initialized to NULLs right after
a kmalloc_array() allocation. Combine these two using kcalloc().

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/vt/consolemap.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index e5fd225e87bd..097ab7d01f8b 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -499,18 +499,16 @@ static int con_unify_unimap(struct vc_data *conp, struct uni_pagedict *p)
static int
con_insert_unipair(struct uni_pagedict *p, u_short unicode, u_short fontpos)
{
- int i, n;
+ int n;
u16 **p1, *p2;

n = UNI_DIR(unicode);
p1 = p->uni_pgdir[n];
if (!p1) {
- p1 = p->uni_pgdir[n] = kmalloc_array(UNI_DIR_ROWS,
- sizeof(u16 *), GFP_KERNEL);
+ p1 = p->uni_pgdir[n] = kcalloc(UNI_DIR_ROWS, sizeof(u16 *),
+ GFP_KERNEL);
if (!p1)
return -ENOMEM;
- for (i = 0; i < UNI_DIR_ROWS; i++)
- p1[i] = NULL;
}

n = UNI_ROW(unicode);
--
2.36.1
\
 
 \ /
  Last update: 2022-06-07 12:54    [W:0.536 / U:0.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site