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.
Showing the changes to kernel/taskstats.c (1 of 21 files). Show all
Unified · Split
| @@ -77,8 +77,7 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp, · 76 unmodified lines | ||
| 77 | 77 | /* |
| 78 | 78 | * If new attributes are added, please revisit this allocation |
| 79 | 79 | */ |
| 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); | |
| 82 | 81 | if (!skb) |
| 83 | 82 | return -ENOMEM; |
| 84 | 83 | |