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

usb: gadget: f_ecm: fix host mac address for multiple instances

In case there are multiple ecm instances, either for multiple
otg controllers, or multiple virtual links using libcomposite,
each instance needs to have its own host mac address string
value for iMACAddress.

Update the source array (ecm_string_defs), every time before
usb_gstrings_attach(). Without that, all links wrongly were
getting the same, last allocated, host mac address, rather
than the correct one, as requested via configfs.

Signed-off-by: Lukasz Nowak <lukasz.nowak@exablue.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Lukasz Nowak and committed by
Felipe Balbi
d3ac41bb eea52743

+2 -1
+2 -1
drivers/usb/gadget/function/f_ecm.c
··· 705 705 ecm_opts->bound = true; 706 706 } 707 707 708 + ecm_string_defs[1].s = ecm->ethaddr; 709 + 708 710 us = usb_gstrings_attach(cdev, ecm_strings, 709 711 ARRAY_SIZE(ecm_string_defs)); 710 712 if (IS_ERR(us)) ··· 930 928 mutex_unlock(&opts->lock); 931 929 return ERR_PTR(-EINVAL); 932 930 } 933 - ecm_string_defs[1].s = ecm->ethaddr; 934 931 935 932 ecm->port.ioport = netdev_priv(opts->net); 936 933 mutex_unlock(&opts->lock);