On Thu, Aug 20, 2020 at 11:40 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > > On Fri, 21 Aug 2020 04:26:12 +0800 kernel test robot <lkp@xxxxxxxxx> wrote: > > > tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > > branch HEAD: 605cbf3d5f20470ec303b79feda3202935f4a142 Add linux-next specific files for 20200820 > > > > Error/Warning in current branch: > > > > fs/notify/fsnotify.c:460 fsnotify() warn: variable dereferenced before check 'inode' (see line 449) > > Yes, this: > > : if (!inode) { > : /* Dirent event - report on TYPE_INODE to dir */ > : inode = dir; > : } else if (mask & FS_EVENT_ON_CHILD) { > : /* > : * Event on child - report on TYPE_INODE to dir if it is > : * watching children and on TYPE_CHILD to child. > : */ > : child = inode; > : inode = dir; > : } > > `inode' is non-NULL here. > > : sb = inode->i_sb; > > So this is OK. > > : /* > : * Optimization: srcu_read_lock() has a memory barrier which can > : * be expensive. It protects walking the *_fsnotify_marks lists. > : * However, if we do not walk the lists, we do not have to do > : * SRCU because we have no references to any objects and do not > : * need SRCU to keep them "alive". > : */ > : if (!sb->s_fsnotify_marks && > : (!mnt || !mnt->mnt_fsnotify_marks) && > : (!inode || !inode->i_fsnotify_marks) && > > So !inode is always false. > > : (!child || !child->i_fsnotify_marks)) > : return 0; > > I assume we can just zap the "!inode ||". Amir & Jan, can you > please take a look? > Andrew, This warning was brought to our attention. We both agreed that we like the code as it is with the unneeded !inode check. https://lore.kernel.org/linux-fsdevel/20200730192537.GB13525@xxxxxxxxxxxxxx/ Thanks, Amir.