Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

atm: idt77252: fix build broken on amd64

idt77252 is broken and wont load on amd64 systems
modprobe idt77252 shows the following

idt77252_init: skb->cb is too small (48 < 56)

Add packed attribute to struct idt77252_skb_prv and struct atm_skb_data
so that the total size can be <= sizeof(skb->cb)
Also convert runtime size check to buildtime size check in
idt77252_init()

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tong Zhang and committed by
David S. Miller
d0a0bbe7 57baf8cc

+3 -12
+1 -10
drivers/atm/idt77252.c
··· 3743 3743 struct sk_buff *skb; 3744 3744 3745 3745 printk("%s: at %p\n", __func__, idt77252_init); 3746 - 3747 - if (sizeof(skb->cb) < sizeof(struct atm_skb_data) + 3748 - sizeof(struct idt77252_skb_prv)) { 3749 - printk(KERN_ERR "%s: skb->cb is too small (%lu < %lu)\n", 3750 - __func__, (unsigned long) sizeof(skb->cb), 3751 - (unsigned long) sizeof(struct atm_skb_data) + 3752 - sizeof(struct idt77252_skb_prv)); 3753 - return -EIO; 3754 - } 3755 - 3746 + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct idt77252_skb_prv) + sizeof(struct atm_skb_data)); 3756 3747 return pci_register_driver(&idt77252_driver); 3757 3748 } 3758 3749
+1 -1
drivers/atm/idt77252.h
··· 789 789 struct scqe tbd; /* Transmit Buffer Descriptor */ 790 790 dma_addr_t paddr; /* DMA handle */ 791 791 u32 pool; /* sb_pool handle */ 792 - }; 792 + } __packed; 793 793 794 794 #define IDT77252_PRV_TBD(skb) \ 795 795 (((struct idt77252_skb_prv *)(ATM_SKB(skb)+1))->tbd)
+1 -1
include/linux/atmdev.h
··· 207 207 struct atm_vcc *vcc; /* ATM VCC */ 208 208 unsigned long atm_options; /* ATM layer options */ 209 209 unsigned int acct_truesize; /* truesize accounted to vcc */ 210 - }; 210 + } __packed; 211 211 212 212 #define VCC_HTABLE_SIZE 32 213 213