tty/vt: consolemap: zero uni_pgdir using kcalloc()
authorJiri Slaby <jslaby@suse.cz>
Tue, 7 Jun 2022 10:49:21 +0000 (12:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jun 2022 11:37:01 +0000 (13:37 +0200)
The newly allocated p->uni_pgdir[n] is initialized to NULLs right after
a kmalloc_array() allocation. Combine these two using kcalloc().

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-11-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/consolemap.c

index e5fd225e87bda2c701f6a60073e5cce224b4f0f7..097ab7d01f8b3480f86e8ad3167fe5f954e44799 100644 (file)
@@ -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);