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

usbb: catc: use correct API for MAC addresses

Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

In the case of catc we need a new temporary buffer to conform
to the rules for DMA coherency. That in turn necessitates
a reworking of error handling in probe().

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Oliver Neukum and committed by
David S. Miller
7ce9a701 2b30da45

+17 -5
+17 -5
drivers/net/usb/catc.c
··· 770 770 struct net_device *netdev; 771 771 struct catc *catc; 772 772 u8 broadcast[ETH_ALEN]; 773 - int pktsz, ret; 773 + u8 *macbuf; 774 + int pktsz, ret = -ENOMEM; 775 + 776 + macbuf = kmalloc(ETH_ALEN, GFP_KERNEL); 777 + if (!macbuf) 778 + goto error; 774 779 775 780 if (usb_set_interface(usbdev, 776 781 intf->altsetting->desc.bInterfaceNumber, 1)) { 777 782 dev_err(dev, "Can't set altsetting 1.\n"); 778 - return -EIO; 783 + ret = -EIO; 784 + goto fail_mem;; 779 785 } 780 786 781 787 netdev = alloc_etherdev(sizeof(struct catc)); 782 788 if (!netdev) 783 - return -ENOMEM; 789 + goto fail_mem; 784 790 785 791 catc = netdev_priv(netdev); 786 792 ··· 876 870 877 871 dev_dbg(dev, "Getting MAC from SEEROM.\n"); 878 872 879 - catc_get_mac(catc, netdev->dev_addr); 873 + catc_get_mac(catc, macbuf); 874 + eth_hw_addr_set(netdev, macbuf); 880 875 881 876 dev_dbg(dev, "Setting MAC into registers.\n"); 882 877 ··· 906 899 } else { 907 900 dev_dbg(dev, "Performing reset\n"); 908 901 catc_reset(catc); 909 - catc_get_mac(catc, netdev->dev_addr); 902 + catc_get_mac(catc, macbuf); 903 + eth_hw_addr_set(netdev, macbuf); 910 904 911 905 dev_dbg(dev, "Setting RX Mode\n"); 912 906 catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast; ··· 925 917 if (ret) 926 918 goto fail_clear_intfdata; 927 919 920 + kfree(macbuf); 928 921 return 0; 929 922 930 923 fail_clear_intfdata: ··· 936 927 usb_free_urb(catc->rx_urb); 937 928 usb_free_urb(catc->irq_urb); 938 929 free_netdev(netdev); 930 + fail_mem: 931 + kfree(macbuf); 932 + error: 939 933 return ret; 940 934 } 941 935