Skip to content

Commit

Permalink
audit: netlink: Move away from NLMSG_NEW().
Browse files Browse the repository at this point in the history
And use nlmsg_data() while we're here too.

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jun 27, 2012
1 parent e052733 commit c64e66c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ static void audit_hold_skb(struct sk_buff *skb)
static void audit_printk_skb(struct sk_buff *skb)
{
struct nlmsghdr *nlh = nlmsg_hdr(skb);
char *data = NLMSG_DATA(nlh);
char *data = nlmsg_data(nlh);

if (nlh->nlmsg_type != AUDIT_EOE) {
if (printk_ratelimit())
Expand Down Expand Up @@ -516,14 +516,15 @@ struct sk_buff *audit_make_reply(int pid, int seq, int type, int done,
if (!skb)
return NULL;

nlh = NLMSG_NEW(skb, pid, seq, t, size, flags);
data = NLMSG_DATA(nlh);
nlh = nlmsg_put(skb, pid, seq, t, size, flags);
if (!nlh)
goto out_kfree_skb;
data = nlmsg_data(nlh);
memcpy(data, payload, size);
return skb;

nlmsg_failure: /* Used by NLMSG_NEW */
if (skb)
kfree_skb(skb);
out_kfree_skb:
kfree_skb(skb);
return NULL;
}

Expand Down Expand Up @@ -680,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
sessionid = audit_get_sessionid(current);
security_task_getsecid(current, &sid);
seq = nlh->nlmsg_seq;
data = NLMSG_DATA(nlh);
data = nlmsg_data(nlh);

switch (msg_type) {
case AUDIT_GET:
Expand Down Expand Up @@ -1060,13 +1061,15 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,

ab->skb = nlmsg_new(AUDIT_BUFSIZ, gfp_mask);
if (!ab->skb)
goto nlmsg_failure;
goto err;

nlh = NLMSG_NEW(ab->skb, 0, 0, type, 0, 0);
nlh = nlmsg_put(ab->skb, 0, 0, type, 0, 0);
if (!nlh)
goto out_kfree_skb;

return ab;

nlmsg_failure: /* Used by NLMSG_NEW */
out_kfree_skb:
kfree_skb(ab->skb);
ab->skb = NULL;
err:
Expand Down

0 comments on commit c64e66c

Please sign in to comment.