History

[NETLINK]: Do precise netlink message allocations where possible

Account for the netlink message header size directly in nlmsg_new() instead of relying on the caller calculate it correctly. Replaces error handling of message construction functions when constructing notifications with bug traps since a failure implies a bug in calculating the size of the skb.

Thomas Graf committed 20 years ago

Commit 339bf981 parent a94f72321 files · +233 −107Browse files

Showing the changes to kernel/taskstats.c (1 of 21 files). Show all

Unified · Split

kernel/taskstats.c+1−2
@@ -77,8 +77,7 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp, · 76 unmodified lines
77 /*77 /*
78 * If new attributes are added, please revisit this allocation78 * If new attributes are added, please revisit this allocation
79 */79 */
80 size = nlmsg_total_size(genlmsg_total_size(size));80 skb = nlmsg_new(genlmsg_total_size(size), GFP_KERNEL);
81 skb = nlmsg_new(size, GFP_KERNEL);
82 if (!skb)81 if (!skb)
83 return -ENOMEM;82 return -ENOMEM;
84 83