lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251017025404.1962110-3-yicongsrfy@163.com>
Date: Fri, 17 Oct 2025 10:54:03 +0800
From: yicongsrfy@....com
To: michal.pecio@...il.com,
	andrew+netdev@...n.ch,
	davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	oliver@...kum.org,
	pabeni@...hat.com
Cc: linux-usb@...r.kernel.org,
	netdev@...r.kernel.org,
	Yi Cong <yicong@...inos.cn>
Subject: [PATCH net v6 2/3] net: usb: ax88179_178a: add USB device driver for config selection

From: Yi Cong <yicong@...inos.cn>

A similar reason was raised in commit ec51fbd1b8a2 ("r8152: add USB
device driver for config selection"):
Linux prioritizes probing non-vendor-specific configurations.

Referring to the implementation of this patch, cfgselect is also
used for ax88179 to override the default configuration selection.

Signed-off-by: Yi Cong <yicong@...inos.cn>
Suggested-by: Michal Pecio <michal.pecio@...il.com>
Link: https://lore.kernel.org/all/20251011075314.572741-1-yicongsrfy@163.com/
Link: https://lore.kernel.org/all/20250928014631.2832243-1-yicongsrfy@163.com/

---
v2: fix warning from checkpatch.
v5: 1. use KBUILD_MODNAME to obtain the module name.
    2. add error handling when usb_register fail.
    3. use .choose_configuration instead of .probe.
    4. reorder deregister logic.
v6: 1. modify the registration order.
    2. fix error return value.
    3. delete unuse check in probe.
---
 drivers/net/usb/ax88179_178a.c | 58 ++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index b034ef8a73ea..bad306a68644 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1941,7 +1941,7 @@ static const struct usb_device_id products[] = {
 MODULE_DEVICE_TABLE(usb, products);
 
 static struct usb_driver ax88179_178a_driver = {
-	.name =		"ax88179_178a",
+	.name =		KBUILD_MODNAME,
 	.id_table =	products,
 	.probe =	usbnet_probe,
 	.suspend =	ax88179_suspend,
@@ -1952,7 +1952,61 @@ static struct usb_driver ax88179_178a_driver = {
 	.disable_hub_initiated_lpm = 1,
 };
 
-module_usb_driver(ax88179_178a_driver);
+static int ax88179_cfgselector_choose_configuration(struct usb_device *udev)
+{
+	struct usb_host_config *c;
+	int i, num_configs;
+
+	/* The vendor mode is not always config #1, so to find it out. */
+	c = udev->config;
+	num_configs = udev->descriptor.bNumConfigurations;
+	for (i = 0; i < num_configs; (i++, c++)) {
+		struct usb_interface_descriptor	*desc = NULL;
+
+		if (!c->desc.bNumInterfaces)
+			continue;
+		desc = &c->intf_cache[0]->altsetting->desc;
+		if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC)
+			break;
+	}
+
+	if (i == num_configs)
+		return -ENODEV;
+
+	return c->desc.bConfigurationValue;
+}
+
+static struct usb_device_driver ax88179_cfgselector_driver = {
+	.name =	KBUILD_MODNAME "-cfgselector",
+	.choose_configuration =	ax88179_cfgselector_choose_configuration,
+	.id_table = products,
+	.generic_subclass = 1,
+	.supports_autosuspend = 1,
+};
+
+static int __init ax88179_driver_init(void)
+{
+	int ret;
+
+	ret = usb_register(&ax88179_178a_driver);
+	if (ret)
+		return ret;
+
+	ret = usb_register_device_driver(&ax88179_cfgselector_driver, THIS_MODULE);
+	if (ret)
+		usb_deregister(&ax88179_178a_driver);
+
+	return ret;
+}
+
+static void __exit ax88179_driver_exit(void)
+{
+	usb_deregister_device_driver(&ax88179_cfgselector_driver);
+	usb_deregister(&ax88179_178a_driver);
+}
+
+module_init(ax88179_driver_init);
+module_exit(ax88179_driver_exit);
 
 MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices");
 MODULE_LICENSE("GPL");
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ