linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] xfs: Add xfs_has_attr and subroutines
@ 2020-07-28 11:57 dan.carpenter
  2020-07-28 17:49 ` Allison Collins
  0 siblings, 1 reply; 2+ messages in thread
From: dan.carpenter @ 2020-07-28 11:57 UTC (permalink / raw)
  To: allison.henderson; +Cc: linux-xfs

Hello Allison Collins,

The patch cfe3d8821c6f: "xfs: Add xfs_has_attr and subroutines" from
Jul 20, 2020, leads to the following Smatch warning:

	fs/xfs/libxfs/xfs_attr.c:1431 xfs_attr_node_get()
	warn: variable dereferenced before check 'state' (see line 1426)

fs/xfs/libxfs/xfs_attr.c
  1398  STATIC int
  1399  xfs_attr_node_get(
  1400          struct xfs_da_args      *args)
  1401  {
  1402          struct xfs_da_state     *state;
  1403          struct xfs_da_state_blk *blk;
  1404          int                     i;
  1405          int                     error;
  1406  
  1407          trace_xfs_attr_node_get(args);
  1408  
  1409          /*
  1410           * Search to see if name exists, and get back a pointer to it.
  1411           */
  1412          error = xfs_attr_node_hasname(args, &state);
  1413          if (error != -EEXIST)
  1414                  goto out_release;
                        ^^^^^^^^^^^^^^^^
state can be NULL.

  1415  
  1416          /*
  1417           * Get the value, local or "remote"
  1418           */
  1419          blk = &state->path.blk[state->path.active - 1];
  1420          error = xfs_attr3_leaf_getvalue(blk->bp, args);
  1421  
  1422          /*
  1423           * If not in a transaction, we have to release all the buffers.
  1424           */
  1425  out_release:
  1426          for (i = 0; i < state->path.active; i++) {
                                ^^^^^^^^^^^^^^^^^^
Dereference

  1427                  xfs_trans_brelse(args->trans, state->path.blk[i].bp);
  1428                  state->path.blk[i].bp = NULL;
  1429          }
  1430  
  1431          if (state)
                    ^^^^^
To late.

  1432                  xfs_da_state_free(state);
  1433          return error;
  1434  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-28 17:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 11:57 [bug report] xfs: Add xfs_has_attr and subroutines dan.carpenter
2020-07-28 17:49 ` Allison Collins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).