From: Salvatore Mesoraca Date: Fri, 8 Jun 2018 00:04:55 +0000 (-0700) Subject: ocfs2: drop a VLA in ocfs2_orphan_del() X-Git-Tag: v4.19~855^2~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64202a21a449837aa155764029216d69019cfb15;p=platform%2Fkernel%2Flinux-rpi.git ocfs2: drop a VLA in ocfs2_orphan_del() Avoid a VLA by using a real constant expression instead of a variable. The compiler should be able to optimize the original code and avoid using an actual VLA. Anyway this change is useful because it will avoid a false positive with -Wvla, it might also help the compiler generating better code. Link: http://lkml.kernel.org/r/1520970710-19732-1-git-send-email-s.mesoraca16@gmail.com Signed-off-by: Salvatore Mesoraca Reviewed-by: Kees Cook Reviewed-by: Andrew Morton Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Joseph Qi Cc: Changwei Ge Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 8dd6f70..b7ca84b 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -2332,8 +2332,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, struct buffer_head *orphan_dir_bh, bool dio) { - const int namelen = OCFS2_DIO_ORPHAN_PREFIX_LEN + OCFS2_ORPHAN_NAMELEN; - char name[namelen + 1]; + char name[OCFS2_DIO_ORPHAN_PREFIX_LEN + OCFS2_ORPHAN_NAMELEN + 1]; struct ocfs2_dinode *orphan_fe; int status = 0; struct ocfs2_dir_lookup_result lookup = { NULL, };