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

Configure Feed

Select the types of activity you want to include in your feed.

usb: gadget: f_ncm: Fix MAC assignment NCM ethernet

This fix is already present in f_ecm.c and was never
propagated to f_ncm.c

When creating multiple NCM ethernet devices
on a composite usb gadget device
each MAC address on the HOST side will be identical.
Having the same MAC on different network interfaces is bad.

This fix updates the MAC address inside the
ncm_strings_defs global during the ncm_bind call.
This ensures each device has a unique MAC.
In f_ecm.c ecm_string_defs is updated in the same way.

The defunct MAC assignment in ncm_alloc has been removed.

Signed-off-by: raub camaioni <raubcameo@gmail.com>
Link: https://lore.kernel.org/r/20250815131358.1047525-1-raubcameo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

raub camaioni and committed by
Greg Kroah-Hartman
956606ba 23cd838a

+2 -1
+2 -1
drivers/usb/gadget/function/f_ncm.c
··· 1463 1463 1464 1464 ncm_opts->bound = true; 1465 1465 1466 + ncm_string_defs[1].s = ncm->ethaddr; 1467 + 1466 1468 us = usb_gstrings_attach(cdev, ncm_strings, 1467 1469 ARRAY_SIZE(ncm_string_defs)); 1468 1470 if (IS_ERR(us)) { ··· 1773 1771 mutex_unlock(&opts->lock); 1774 1772 return ERR_PTR(-EINVAL); 1775 1773 } 1776 - ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr; 1777 1774 1778 1775 spin_lock_init(&ncm->lock); 1779 1776 ncm_reset_values(ncm);