Hi, On 5/19/26 2:44 PM, Sascha Hauer wrote: > UBIFS uses kmem_cache_alloc() to allocate an ubifs_inode. The memory > returned from kmem_cache_alloc() is not zeroed. ubifs_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 <[email protected]> > --- > fs/ubifs/super.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c > index 45037b42ea..4022270d4c 100644 > --- a/fs/ubifs/super.c > +++ b/fs/ubifs/super.c > @@ -1128,6 +1128,7 @@ static void kill_ubifs_super(struct super_block *s) > */ > static void inode_slab_ctor(void *obj) > { > + memset(obj, 0, sizeof(struct inode));
This works because inode is the first member of struct ubifs_inode, but I would prefer to avoid depending on that as it might change with a future update. Can't we just zero all of struct ubifs_inode here to be on the safe side? Cheers, Ahmad > } > > static int __init ubifs_init(void) -- 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 |
