[PATCH 1/1] xfs: Fix Smatch warning in xfs_attr_node_get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 derefrence it.  Go straight to out.

Signed-off-by: Allison Collins <allison.henderson@xxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_attr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index e5ec9ed..90b7b24 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -1409,6 +1409,9 @@ xfs_attr_node_get(
 	 * Search to see if name exists, and get back a pointer to it.
 	 */
 	error = xfs_attr_node_hasname(args, &state);
+	if (!state)
+		goto out;
+
 	if (error != -EEXIST)
 		goto out_release;
 
@@ -1426,7 +1429,7 @@ xfs_attr_node_get(
 		xfs_trans_brelse(args->trans, state->path.blk[i].bp);
 		state->path.blk[i].bp = NULL;
 	}
-
+out:
 	if (state)
 		xfs_da_state_free(state);
 	return error;
-- 
2.7.4




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux