Commit ee080e6ce93d5993390bccf68c1df5efd9351276
Committed by
Al Viro
1 parent
038cbcf65f
Exists in
master
and in
39 other branches
Audit: cleanup netlink mesg handling
The audit handling of netlink messages is all over the place. Clean things up, use predetermined macros, generally make it more readable. Signed-off-by: Eric Paris <eparis@redhat.com>
Showing 1 changed file with 15 additions and 15 deletions Side-by-side Diff
kernel/audit.c
... | ... | @@ -528,22 +528,20 @@ |
528 | 528 | { |
529 | 529 | struct sk_buff *skb; |
530 | 530 | struct nlmsghdr *nlh; |
531 | - int len = NLMSG_SPACE(size); | |
532 | 531 | void *data; |
533 | 532 | int flags = multi ? NLM_F_MULTI : 0; |
534 | 533 | int t = done ? NLMSG_DONE : type; |
535 | 534 | |
536 | - skb = alloc_skb(len, GFP_KERNEL); | |
535 | + skb = nlmsg_new(size, GFP_KERNEL); | |
537 | 536 | if (!skb) |
538 | 537 | return NULL; |
539 | 538 | |
540 | - nlh = NLMSG_PUT(skb, pid, seq, t, size); | |
541 | - nlh->nlmsg_flags = flags; | |
542 | - data = NLMSG_DATA(nlh); | |
539 | + nlh = NLMSG_NEW(skb, pid, seq, t, size, flags); | |
540 | + data = NLMSG_DATA(nlh); | |
543 | 541 | memcpy(data, payload, size); |
544 | 542 | return skb; |
545 | 543 | |
546 | -nlmsg_failure: /* Used by NLMSG_PUT */ | |
544 | +nlmsg_failure: /* Used by NLMSG_NEW */ | |
547 | 545 | if (skb) |
548 | 546 | kfree_skb(skb); |
549 | 547 | return NULL; |
550 | 548 | |
551 | 549 | |
... | ... | @@ -1083,18 +1081,20 @@ |
1083 | 1081 | goto err; |
1084 | 1082 | } |
1085 | 1083 | |
1086 | - ab->skb = alloc_skb(AUDIT_BUFSIZ, gfp_mask); | |
1087 | - if (!ab->skb) | |
1088 | - goto err; | |
1089 | - | |
1090 | 1084 | ab->ctx = ctx; |
1091 | 1085 | ab->gfp_mask = gfp_mask; |
1092 | - nlh = (struct nlmsghdr *)skb_put(ab->skb, NLMSG_SPACE(0)); | |
1093 | - nlh->nlmsg_type = type; | |
1094 | - nlh->nlmsg_flags = 0; | |
1095 | - nlh->nlmsg_pid = 0; | |
1096 | - nlh->nlmsg_seq = 0; | |
1086 | + | |
1087 | + ab->skb = nlmsg_new(AUDIT_BUFSIZ, gfp_mask); | |
1088 | + if (!ab->skb) | |
1089 | + goto nlmsg_failure; | |
1090 | + | |
1091 | + nlh = NLMSG_NEW(ab->skb, 0, 0, type, 0, 0); | |
1092 | + | |
1097 | 1093 | return ab; |
1094 | + | |
1095 | +nlmsg_failure: /* Used by NLMSG_NEW */ | |
1096 | + kfree_skb(ab->skb); | |
1097 | + ab->skb = NULL; | |
1098 | 1098 | err: |
1099 | 1099 | audit_buffer_free(ab); |
1100 | 1100 | return NULL; |