xfs: initialize error in xfs_defer_finish_one
PATCH 1/1 xfs: initialize error in xfs_defer_finish_one
Path through non-void function 'xfs_defer_finish_one' may return error uninitialized if no iteration of 'list_for_each_safe' occurs. Fix this by initializing error.
--- fs/xfs/libxfs/xfs_defer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_defer.c +1 -1
@@ -468,7 +468,7 @@ xfs_defer_finish_one(const struct xfs_defer_op_type *ops = defer_op_types[dfp->dfp_type];struct xfs_btree_cur *state =NULL ;struct list_head *li, *n; -int error; +int error =0 ;trace_xfs_defer_pending_finish (tp->t_mountp, dfp);
Signature · 1 line
2.31.1
Quoted 3 lines · Sherry Yang
Path through non-void function '
xfs_defer_finish_one' may return error uninitialized if no iteration of 'list_for_each_safe' occurs. Fix this by initializing error.
I didn't think this situation was possible - how do we get deferred work queued with no work items on it?
If we can return an uninitialised error from xfs_defer_finish_one() because of an empty queued work, then something else has gone wrong earlier in the work deferral process. If this can actually happen, then we need to fix whatever is creating the empty work rather than paper over it by initialising the error being returned for empty works...
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 8 lines · Dave Chinner
Quoted 3 lines · Sherry Yang
Path through non-void function '
xfs_defer_finish_one' may return error uninitialized if no iteration of 'list_for_each_safe' occurs. Fix this by initializing error.I didn't think this situation was possible - how do we get deferred work queued with no work items on it?
Quoted 6 lines
If we can return an uninitialised error from
xfs_defer_finish_one()because of an empty queued work, then something else has gone wrong earlier in the work deferral process. If this can actually happen, then we need to fix whatever is creating the empty work rather than paper over it by initialising the error being returned for empty works...
/me bets this is a response to a static checker that doesn't know that list_empty(&dfp->dfp_work) == false in all circumstances. It's not possible for tp->t_dfops to contain an xfs_defer_pending with no work items.
--D
Quoted 6 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 19 lines · Darrick J. Wong
Quoted 8 lines · Dave Chinner
Quoted 3 lines · Sherry Yang
Path through non-void function '
xfs_defer_finish_one' may return error uninitialized if no iteration of 'list_for_each_safe' occurs. Fix this by initializing error.I didn't think this situation was possible - how do we get deferred work queued with no work items on it?
Quoted 6 lines
If we can return an uninitialised error from
xfs_defer_finish_one()because of an empty queued work, then something else has gone wrong earlier in the work deferral process. If this can actually happen, then we need to fix whatever is creating the empty work rather than paper over it by initialising the error being returned for empty works...
Quoted 4 lines
/me bets this is a response to a static checker that doesn't know that
list_empty(&dfp->dfp_work)== false in all circumstances. It's not possible fortp->t_dfopsto contain anxfs_defer_pendingwith no work items.
Hi Darrick,
You’re correct. This is a false positive bug detected by our static code analysis tool. Sorry for the noise.
Sherry
Quoted 9 lines
--D
Quoted 6 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 24 lines · Sherry Yang
Quoted 19 lines · Darrick J. Wong
Quoted 8 lines · Dave Chinner
Quoted 3 lines · Sherry Yang
Path through non-void function '
xfs_defer_finish_one' may return error uninitialized if no iteration of 'list_for_each_safe' occurs. Fix this by initializing error.I didn't think this situation was possible - how do we get deferred work queued with no work items on it?
Quoted 6 lines
If we can return an uninitialised error from
xfs_defer_finish_one()because of an empty queued work, then something else has gone wrong earlier in the work deferral process. If this can actually happen, then we need to fix whatever is creating the empty work rather than paper over it by initialising the error being returned for empty works...Quoted 4 lines
/me bets this is a response to a static checker that doesn't know that
list_empty(&dfp->dfp_work)== false in all circumstances. It's not possible fortp->t_dfopsto contain anxfs_defer_pendingwith no work items.
Quoted 4 lines
Hi Darrick,
You’re correct. This is a false positive bug detected by our static code analysis tool. Sorry for the noise.
Well, thank /you/ for running smatch/sparse/whatever on the XFS code base. Let us know if you find any other oddities, since it does tend to find things every now and then. :)
--D
Quoted 11 lines
Sherry
Quoted 9 lines
--D
Quoted 6 lines
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]