From: Kumar Sanghvi Date: Mon, 27 Sep 2010 23:10:42 +0000 (+0000) Subject: Phonet: Correct header retrieval after pskb_may_pull X-Git-Tag: firefly_0821_release~10186^2~822 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=81f9ffe4909999ea0608b8a77e7aa289cba84bf8;p=firefly-linux-kernel-4.4.55.git Phonet: Correct header retrieval after pskb_may_pull [ Upstream commit a91e7d471e2e384035b9746ea707ccdcd353f5dd ] Retrieve the header after doing pskb_may_pull since, pskb_may_pull could change the buffer structure. This is based on the comment given by Eric Dumazet on Phonet Pipe controller patch for a similar problem. Signed-off-by: Kumar Sanghvi Acked-by: Linus Walleij Acked-by: Eric Dumazet Acked-by: RĂ©mi Denis-Courmont Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 5f32d217535b..9cdd35e78759 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c @@ -224,12 +224,13 @@ static void pipe_grant_credits(struct sock *sk) static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb) { struct pep_sock *pn = pep_sk(sk); - struct pnpipehdr *hdr = pnp_hdr(skb); + struct pnpipehdr *hdr; int wake = 0; if (!pskb_may_pull(skb, sizeof(*hdr) + 4)) return -EINVAL; + hdr = pnp_hdr(skb); if (hdr->data[0] != PN_PEP_TYPE_COMMON) { LIMIT_NETDEBUG(KERN_DEBUG"Phonet unknown PEP type: %u\n", (unsigned)hdr->data[0]);