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.

ocfs2: annotate more flexible array members with __counted_by_le()

Annotate flexible array members of 'struct ocfs2_local_alloc' and 'struct
ocfs2_inline_data' with '__counted_by_le()' attribute to improve array
bounds checking when CONFIG_UBSAN_BOUNDS is enabled, and prefer the
convenient 'memset()' over an explicit loop to simplify
'ocfs2_clear_local_alloc()'.

Link: https://lkml.kernel.org/r/20251021105518.119953-1-dmantipov@yandex.ru
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Dmitry Antipov and committed by
Andrew Morton
29300f92 e0b0f283

+3 -5
+1 -3
fs/ocfs2/localalloc.c
··· 905 905 static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc) 906 906 { 907 907 struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); 908 - int i; 909 908 910 909 alloc->id1.bitmap1.i_total = 0; 911 910 alloc->id1.bitmap1.i_used = 0; 912 911 la->la_bm_off = 0; 913 - for(i = 0; i < le16_to_cpu(la->la_size); i++) 914 - la->la_bitmap[i] = 0; 912 + memset(la->la_bitmap, 0, le16_to_cpu(la->la_size)); 915 913 } 916 914 917 915 #if 0
+2 -2
fs/ocfs2/ocfs2_fs.h
··· 641 641 __le16 la_size; /* Size of included bitmap, in bytes */ 642 642 __le16 la_reserved1; 643 643 __le64 la_reserved2; 644 - /*10*/ __u8 la_bitmap[]; 644 + /*10*/ __u8 la_bitmap[] __counted_by_le(la_size); 645 645 }; 646 646 647 647 /* ··· 654 654 * for data, starting at id_data */ 655 655 __le16 id_reserved0; 656 656 __le32 id_reserved1; 657 - __u8 id_data[]; /* Start of user data */ 657 + __u8 id_data[] __counted_by_le(id_count); /* Start of user data */ 658 658 }; 659 659 660 660 /*