All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-nonmm-stable] initramfs-make-dir_entryname-a-flexible-array-member.patch removed from -mm tree
@ 2022-05-10  4:18 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-05-10  4:18 UTC (permalink / raw)
  To: mm-commits, willy, viro, mwilck, christian.brauner, ddiss, akpm


The quilt patch titled
     Subject: initramfs: make dir_entry.name a flexible array member
has been removed from the -mm tree.  Its filename was
     initramfs-make-dir_entryname-a-flexible-array-member.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: David Disseldorp <ddiss@suse.de>
Subject: initramfs: make dir_entry.name a flexible array member

dir_entry.name is currently allocated via a separate kstrdup().  Change it
to a flexible array member and allocate it along with struct dir_entry.

Link: https://lkml.kernel.org/r/20220404093429.27570-3-ddiss@suse.de
Signed-off-by: David Disseldorp <ddiss@suse.de>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 init/initramfs.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- a/init/initramfs.c~initramfs-make-dir_entryname-a-flexible-array-member
+++ a/init/initramfs.c
@@ -130,17 +130,20 @@ static long __init do_utime(char *filena
 static __initdata LIST_HEAD(dir_list);
 struct dir_entry {
 	struct list_head list;
-	char *name;
 	time64_t mtime;
+	char name[];
 };
 
 static void __init dir_add(const char *name, time64_t mtime)
 {
-	struct dir_entry *de = kmalloc(sizeof(struct dir_entry), GFP_KERNEL);
+	size_t nlen = strlen(name) + 1;
+	struct dir_entry *de;
+
+	de = kmalloc(sizeof(struct dir_entry) + nlen, GFP_KERNEL);
 	if (!de)
 		panic_show_mem("can't allocate dir_entry buffer");
 	INIT_LIST_HEAD(&de->list);
-	de->name = kstrdup(name, GFP_KERNEL);
+	strscpy(de->name, name, nlen);
 	de->mtime = mtime;
 	list_add(&de->list, &dir_list);
 }
@@ -151,7 +154,6 @@ static void __init dir_utime(void)
 	list_for_each_entry_safe(de, tmp, &dir_list, list) {
 		list_del(&de->list);
 		do_utime(de->name, de->mtime);
-		kfree(de->name);
 		kfree(de);
 	}
 }
_

Patches currently in -mm which might be from ddiss@suse.de are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-10  4:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10  4:18 [merged mm-nonmm-stable] initramfs-make-dir_entryname-a-flexible-array-member.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.