Re: [bug report] xfs: Add xfs_has_attr and subroutines

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

 





On 7/28/20 4:57 AM, dan.carpenter@xxxxxxxxxx wrote:
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

Thanks for the catch, with send a patch for this

Allison



[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