xfs: avoid double-free in xfs_attr_node_addname
authorEric Sandeen <sandeen@redhat.com>
Thu, 1 Aug 2013 01:18:54 +0000 (20:18 -0500)
committerBen Myers <bpm@sgi.com>
Tue, 13 Aug 2013 20:48:01 +0000 (15:48 -0500)
xfs_attr_node_addname()'s error handling tests whether it
should free "state" in the out: error handling label:

out:
        if (state)
                xfs_da_state_free(state);

but an earlier free doesn't set state to NULL afterwards; this
could lead to a double free.  Fix it by setting state to NULL
after it's freed.

This was found by Coverity.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_attr.c

index 176dbb66282d4910f9b14ec401912cbed8a89838..ddcf2267ffa6fdf1bcf33cf7439c6b379472c2b4 100644 (file)
@@ -1014,6 +1014,7 @@ restart:
                         * have been a b-tree.
                         */
                        xfs_da_state_free(state);
+                       state = NULL;
                        xfs_bmap_init(args->flist, args->firstblock);
                        error = xfs_attr3_leaf_to_node(args);
                        if (!error) {