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
7777 /*
7878 * If new attributes are added, please revisit this allocation
7979 */
80− size = nlmsg_total_size(genlmsg_total_size(size));
81− skb = nlmsg_new(size, GFP_KERNEL);
80+ skb = nlmsg_new(genlmsg_total_size(size), GFP_KERNEL);
8281 if (!skb)
8382 return -ENOMEM;
8483