Skip to content

Commit

Permalink
genetlink: Fix a memory leak on error path
Browse files Browse the repository at this point in the history
In genl_register_family(), when idr_alloc() fails,
we forget to free the memory we possibly allocate for
family->attrbuf.

Reported-by: Hulk Robot <[email protected]>
Fixes: 2ae0f17 ("genetlink: use idr to track families")
Signed-off-by: YueHaibing <[email protected]>
Reviewed-by: Kirill Tkhai <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
YueHaibing authored and davem330 committed Mar 21, 2019
1 parent 33872d7 commit ceabee6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/netlink/genetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ int genl_register_family(struct genl_family *family)
start, end + 1, GFP_KERNEL);
if (family->id < 0) {
err = family->id;
goto errout_locked;
goto errout_free;
}

err = genl_validate_assign_mc_groups(family);
Expand All @@ -385,6 +385,7 @@ int genl_register_family(struct genl_family *family)

errout_remove:
idr_remove(&genl_fam_idr, family->id);
errout_free:
kfree(family->attrbuf);
errout_locked:
genl_unlock_all();
Expand Down

0 comments on commit ceabee6

Please sign in to comment.