[PATCH 2/2] fs: jffs2: zero initialize allocated inode
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue May 19 06:35:31 PDT 2026
On 5/19/26 3:28 PM, Sascha Hauer wrote:
> JFFS2 uses kmem_cache_alloc() to allocate an ubifs_inode. The memory
> returned from kmem_cache_alloc() is not zeroed. jffs2_alloc_inode()
> zeroes all fields in the ubifs_inode except the embedded struct inode.
> In Linux this is done in the kmem_cache constructor function which calls
> inode_init_once(). In barebox we have the constructor function as well,
> but we don't have an equivalent of inode_init_once(), so the constructor
> is empty. zero the inode in the constructor instead so that barebox
> gets a zeroed inode.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
> fs/jffs2/super.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
> index b9a5b99744..6546943173 100644
> --- a/fs/jffs2/super.c
> +++ b/fs/jffs2/super.c
> @@ -55,8 +55,11 @@ static void jffs2_destroy_inode(struct inode *inode)
> kmem_cache_free(jffs2_inode_cachep, f);
> }
>
> -static void jffs2_i_init_once(void *foo)
> +static void jffs2_i_init_once(void *obj)
> {
> + struct jffs2_inode_info *f = obj;
> +
> + memset(&f->vfs_inode, 0, sizeof(f->vfs_inode));
> }
>
> static const struct super_operations jffs2_super_operations =
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list