{"id":"CVE-2026-138844","summary":"usb: core: don't set drvdata to NULL in usb_unbind_interface()","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nusb: core: don't set drvdata to NULL in usb_unbind_interface()\n\nusb_unbind_interface() serves as the remove() callback of struct\nusb_driver and calls usb_set_intfdata(intf, NULL) to clear the bus\ndevice private data pointer.\n\nHowever, the driver core code already sets the bus device private data\npointer to NULL in device_unbind_cleanup() *after* devres_release_all(),\nwhich makes the call redundant.\n\nIn addition, it can create unexpected NULL pointer dereference scenarios\nwhen drivers use managed APIs.\n\n\tint probe(struct usb_interface *intf,\n\t\t  const struct usb_device_id *id)\n\t{\n\t\tstruct data *data;\n\t\tint ret;\n\n\t\tdata = devm_kzalloc(&intf-\u003edev, sizeof(*data), GFP_KERNEL);\n\t\tif (!data)\n\t\t\treturn -ENOMEM;\n\n\t\tret = devm_device_add_group(&intf-\u003edev, &foo_attr_group);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\t...\n\t}\n\n\tssize_t foo_value_show(struct device *dev, struct device_attribute *attr,\n\t\t\t       char *buf)\n\t{\n\t\tstruct usb_interface *intf = to_usb_interface(dev);\n\t\tstruct data *data = usb_get_intfdata(intf);\n\n\t\t/* Potential NULL pointer dereference */\n\t\treturn sysfs_emit(buf, \"%u\\n\", data-\u003evalue);\n\t}\n\nNothing prevents usb_unbind_interface() to race with foo_value_show()\nand set usb_set_intfdata(intf, NULL).\n\nThe same applies to the unwind path of usb_probe_interface(), which also\ncalls usb_set_intfdata(intf, NULL).\n\nBesides that, the Rust driver core code manages a driver's bus device\nprivate data and destroys it in device_unbind_cleanup().\n\nIf usb_unbind_interface() sets the pointer to NULL prematurely, the Rust\ndriver core code sees NULL, and hence skips the destructor of the bus\ndevice private data, which leaks all its resources.\n\nThus, drop usb_set_intfdata(intf, NULL) from usb_probe_interface() and\nusb_unbind_interface(), and move it to usb_driver_release_interface(),\nwhich manually calls the remove() callback of struct usb_driver and\nhence can't rely on the driver core.","modified":"2026-12-01T21:02:34.435572434Z","published":"2026-11-30T13:25:30.613Z","database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/138xxx/CVE-2026-138844.json"},"references":[{"type":"WEB","url":"https://git.kernel.org/stable/c/8f0d16174102863936d583c90258ea02bf06205c"},{"type":"WEB","url":"https://git.kernel.org/stable/c/c460161d08103ee44c670e94da8c3c70ae82f4be"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/138xxx/CVE-2026-138844.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-138844"},{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"a995fe1a3aa78b7d06cc1cc7b6b8436c5e93b07f"},{"fixed":"c460161d08103ee44c670e94da8c3c70ae82f4be"},{"fixed":"8f0d16174102863936d583c90258ea02bf06205c"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-138844.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"6.19.0"},{"fixed":"7.3.4"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-138844.json"}}],"schema_version":"1.9.2"}