Skip to content

Commit

Permalink
connector: bump skb->users before callback invocation
Browse files Browse the repository at this point in the history
Dmitry reports memleak with syskaller program.
Problem is that connector bumps skb usecount but might not invoke callback.

So move skb_get to where we invoke the callback.

Reported-by: Dmitry Vyukov <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Florian Westphal authored and davem330 committed Jan 5, 2016
1 parent 3934aa4 commit 55285bf
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/connector/connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,21 @@ static int cn_call_callback(struct sk_buff *skb)
*
* It checks skb, netlink header and msg sizes, and calls callback helper.
*/
static void cn_rx_skb(struct sk_buff *__skb)
static void cn_rx_skb(struct sk_buff *skb)
{
struct nlmsghdr *nlh;
struct sk_buff *skb;
int len, err;

skb = skb_get(__skb);

if (skb->len >= NLMSG_HDRLEN) {
nlh = nlmsg_hdr(skb);
len = nlmsg_len(nlh);

if (len < (int)sizeof(struct cn_msg) ||
skb->len < nlh->nlmsg_len ||
len > CONNECTOR_MAX_MSG_SIZE) {
kfree_skb(skb);
len > CONNECTOR_MAX_MSG_SIZE)
return;
}

err = cn_call_callback(skb);
err = cn_call_callback(skb_get(skb));
if (err < 0)
kfree_skb(skb);
}
Expand Down

0 comments on commit 55285bf

Please sign in to comment.