Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hfs: make proper initalization of struct hfs_find_data

Potenatially, __hfs_ext_read_extent() could operate by
not initialized values of fd->key after hfs_brec_find() call:

static inline int __hfs_ext_read_extent(struct hfs_find_data *fd, struct hfs_extent *extent,
u32 cnid, u32 block, u8 type)
{
int res;

hfs_ext_build_key(fd->search_key, cnid, block, type);
fd->key->ext.FNum = 0;
res = hfs_brec_find(fd);
if (res && res != -ENOENT)
return res;
if (fd->key->ext.FNum != fd->search_key->ext.FNum ||
fd->key->ext.FkType != fd->search_key->ext.FkType)
return -ENOENT;
if (fd->entrylength != sizeof(hfs_extent_rec))
return -EIO;
hfs_bnode_read(fd->bnode, extent, fd->entryoffset, sizeof(hfs_extent_rec));
return 0;
}

This patch changes kmalloc() on kzalloc() in hfs_find_init()
and intializes fd->record, fd->keyoffset, fd->keylength,
fd->entryoffset, fd->entrylength for the case if hfs_brec_find()
has been found nothing in the b-tree node.

Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
cc: Yangtao Li <frank.li@vivo.com>
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/20250818225252.126427-1-slava@dubeyko.com
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>

+7 -1
+7 -1
fs/hfs/bfind.c
··· 21 21 22 22 fd->tree = tree; 23 23 fd->bnode = NULL; 24 - ptr = kmalloc(tree->max_key_len * 2 + 4, GFP_KERNEL); 24 + ptr = kzalloc(tree->max_key_len * 2 + 4, GFP_KERNEL); 25 25 if (!ptr) 26 26 return -ENOMEM; 27 27 fd->search_key = ptr; ··· 114 114 u32 nidx, parent; 115 115 __be32 data; 116 116 int height, res; 117 + 118 + fd->record = -1; 119 + fd->keyoffset = -1; 120 + fd->keylength = -1; 121 + fd->entryoffset = -1; 122 + fd->entrylength = -1; 117 123 118 124 tree = fd->tree; 119 125 if (fd->bnode)