Skip to content

Commit

Permalink
caif: Do not dereference NULL in chnl_recv_cb()
Browse files Browse the repository at this point in the history
In net/caif/chnl_net.c::chnl_recv_cb() we call skb_header_pointer()
which may return NULL, but we do not check for a NULL pointer before
dereferencing it.
This patch adds such a NULL check and properly free's allocated memory
and return an error (-EINVAL) on failure - much better than crashing..

Signed-off-by: Jesper Juhl <[email protected]>
Acked-by: Sjur Brændeland <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jjuhl authored and davem330 committed Aug 20, 2012
1 parent 6c71bec commit d92c7f8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/caif/chnl_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)

/* check the version of IP */
ip_version = skb_header_pointer(skb, 0, 1, &buf);
if (!ip_version) {
kfree_skb(skb);
return -EINVAL;
}

switch (*ip_version >> 4) {
case 4:
Expand Down

0 comments on commit d92c7f8

Please sign in to comment.