• Wolfgang Grandegger's avatar
    can: provide library functions for skb allocation · 7b6856a0
    Wolfgang Grandegger authored
    This patch makes the private functions alloc_can_skb() and
    alloc_can_err_skb() of the at91_can driver public and adapts all
    drivers to use these. While making the patch I realized, that
    the skb's are *not* setup consistently. It's now done as shown
    below:
    
      skb->protocol = htons(ETH_P_CAN);
      skb->pkt_type = PACKET_BROADCAST;
      skb->ip_summed = CHECKSUM_UNNECESSARY;
      *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
      memset(*cf, 0, sizeof(struct can_frame));
    
    The frame is zeroed out to avoid uninitialized data to be passed to
    user space. Some drivers or library code did not set "pkt_type" or
    "ip_summed". Also,  "__constant_htons()" should not be used for
    runtime invocations, as pointed out by David Miller.
    Signed-off-by: default avatarWolfgang Grandegger <wg@grandegger.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    7b6856a0
at91_can.c 28.9 KB