Skip to content

Commit

Permalink
btrfs: Fix kfree of member instead of structure
Browse files Browse the repository at this point in the history
Correctness fix: The kfree calls in the add_delayed_* functions free
the node that's passed into it, but the node is a member of another
structure. It works because it's always the first member of the
containing structure, but it should really be using the containing
structure itself.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
  • Loading branch information
Jeff Mahoney authored and David Sterba committed Mar 22, 2012
1 parent 43c04fb commit cddcd80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/btrfs/delayed-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static noinline int add_delayed_ref_head(struct btrfs_fs_info *fs_info,
* we've updated the existing ref, free the newly
* allocated ref
*/
kfree(ref);
kfree(head_ref);
} else {
delayed_refs->num_heads++;
delayed_refs->num_heads_ready++;
Expand Down Expand Up @@ -549,7 +549,7 @@ static noinline int add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
* we've updated the existing ref, free the newly
* allocated ref
*/
kfree(ref);
kfree(full_ref);
} else {
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
Expand Down Expand Up @@ -611,7 +611,7 @@ static noinline int add_delayed_data_ref(struct btrfs_fs_info *fs_info,
* we've updated the existing ref, free the newly
* allocated ref
*/
kfree(ref);
kfree(full_ref);
} else {
delayed_refs->num_entries++;
trans->delayed_ref_updates++;
Expand Down

0 comments on commit cddcd80

Please sign in to comment.