xfs: Fix Smatch warning in xfs_attr_node_get
PATCH v2 1/1 xfs: Fix Smatch warning in xfs_attr_node_get
Fix warning: variable dereferenced before check 'state' in xfs_attr_node_get. If xfs_attr_node_hasname fails, it may return a null state. If state is null, do not release paths or derefrence state
--- fs/xfs/libxfs/xfs_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_attr.c +1 -1
@@ -1422,7 +1422,7 @@ xfs_attr_node_get(* If not in a transaction, we have to release all the buffers. */ out_release: -for (i =0 ; i < state->path.active; i++) { +for (i =0 ; i < state && state->path.active; i++) {xfs_trans_brelse (args->trans, state->path.blk[i].bp); state->path.blk[i].bp =NULL ; }
Signature · 1 line
2.7.4
Quoted 5 lines · Allison Collins
Fix warning: variable dereferenced before check 'state' in
xfs_attr_node_get. Ifxfs_attr_node_hasnamefails, it may return a null state. If state is null, do not release paths or derefrence stateSigned-off-by Allison Collins <[email protected]>
Looks ok, though I folded all these into the for-next rebase (and then forgot to push send on this...)
--D
Quoted 20 lines
--- fs/xfs/libxfs/xfs_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/libxfs/xfs_attr.c +1
-1@@ -1422,7 +1422,7 @@ xfs_attr_node_get(* If not in a transaction, we have to release all the buffers. */ out_release: -for (i =0 ; i < state->path.active; i++) { +for (i =0 ; i < state && state->path.active; i++) {xfs_trans_brelse (args->trans, state->path.blk[i].bp); state->path.blk[i].bp =NULL ; }Signature · 1 line
2.7.4
Quoted 10 lines · Darrick J. Wong
Quoted 5 lines · Allison Collins
Fix warning: variable dereferenced before check 'state' in
xfs_attr_node_get. Ifxfs_attr_node_hasnamefails, it may return a null state. If state is null, do not release paths or derefrence stateSigned-off-by Allison Collins <[email protected]>Looks ok, though I folded all these into the for-next rebase (and then forgot to push send on this...)
No worries, thank you!
Allison
Quoted 24 lines
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 20 lines
--- fs/xfs/libxfs/xfs_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/libxfs/xfs_attr.c +1
-1@@ -1422,7 +1422,7 @@ xfs_attr_node_get(* If not in a transaction, we have to release all the buffers. */ out_release: -for (i =0 ; i < state->path.active; i++) { +for (i =0 ; i < state && state->path.active; i++) {xfs_trans_brelse (args->trans, state->path.blk[i].bp); state->path.blk[i].bp =NULL ; }Signature · 1 line
2.7.4