From: Darrick J. Wong Date: Mon, 6 May 2019 22:00:29 +0000 (-0400) Subject: xfs: zero initialize highstale and lowstale in xfs_dir2_leaf_addname X-Git-Tag: v5.1.0-rc0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=732a9d49fb472a513eea0d1b9b84dd3a3c94e336;p=thirdparty%2Fxfsprogs-dev.git xfs: zero initialize highstale and lowstale in xfs_dir2_leaf_addname Source kernel commit: f51fac68926235ef5bc482eb759d2c60b86fa358 Smatch complains about the following: fs/xfs/libxfs/xfs_dir2_leaf.c:848 xfs_dir2_leaf_addname() error: uninitialized symbol 'lowstale'. fs/xfs/libxfs/xfs_dir2_leaf.c:849 xfs_dir2_leaf_addname() error: uninitialized symbol 'highstale'. I don't think there's any incorrect behavior associated with the uninitialized variable, but as the author of the previous zero-init patch points out, it's best not to be passing around pointers to uninitialized stack areas. Signed-off-by: Darrick J. Wong Reviewed-by: Nathan Chancellor Reviewed-by: Allison Henderson Reviewed-by: Bill O'Donnell Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index d5ece2ccc..68267e03f 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -571,7 +571,7 @@ xfs_dir2_leaf_addname( xfs_dir2_data_unused_t *dup; /* data unused entry */ int error; /* error return value */ int grown; /* allocated new data block */ - int highstale; /* index of next stale leaf */ + int highstale = 0; /* index of next stale leaf */ int i; /* temporary, index */ int index; /* leaf table position */ struct xfs_buf *lbp; /* leaf's buffer */ @@ -580,7 +580,7 @@ xfs_dir2_leaf_addname( xfs_dir2_leaf_entry_t *lep; /* leaf entry table pointer */ int lfloglow; /* low leaf logging index */ int lfloghigh; /* high leaf logging index */ - int lowstale; /* index of prev stale leaf */ + int lowstale = 0; /* index of prev stale leaf */ xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */ int needbytes; /* leaf block bytes needed */ int needlog; /* need to log data header */