All of lore.kernel.org
 help / color / mirror / Atom feed
From: <dan.carpenter@oracle.com>
To: allison.henderson@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [bug report] xfs: Add xfs_has_attr and subroutines
Date: Tue, 28 Jul 2020 14:57:52 +0300	[thread overview]
Message-ID: <20200728115752.GA426300@mwanda> (raw)

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

             reply	other threads:[~2020-07-28 11:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28 11:57 dan.carpenter [this message]
2020-07-28 17:49 ` [bug report] xfs: Add xfs_has_attr and subroutines Allison Collins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200728115752.GA426300@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=allison.henderson@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.