{"id":"CVE-2026-138844","aliases":["CVE-2026-138844"],"related":[],"kind":"vulnerability","state":"published","title":"usb: core: don't set drvdata to NULL in usb_unbind_interface()","summary":"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->dev, sizeof(*data), GFP_KERNEL);\n\t\tif (!data)\n\t\t\treturn -ENOMEM;\n\n\t\tret = devm_device_add_group(&intf->dev, &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->value);\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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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->dev, sizeof(*data), GFP_KERNEL);\n\t\tif (!data)\n\t\t\treturn -ENOMEM;\n\n\t\tret = devm_device_add_group(&intf->dev, &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->value);\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.","source":"cvelist"}],"published":"2026-11-30T13:25:30.613Z","modified":"2026-11-30T14:17:39.980Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"a995fe1a3aa78b7d06cc1cc7b6b8436c5e93b07f","fixed":"c460161d08103ee44c670e94da8c3c70ae82f4be","status":"affected"},{"type":"git","introduced":"a995fe1a3aa78b7d06cc1cc7b6b8436c5e93b07f","fixed":"8f0d16174102863936d583c90258ea02bf06205c","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.19","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.19","status":"unaffected"},{"type":"semver","introduced":"7.3.4","lastAffected":"7.3.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.4-rc1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/c460161d08103ee44c670e94da8c3c70ae82f4be","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/8f0d16174102863936d583c90258ea02bf06205c","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-138844","url":"https://www.cve.org/CVERecord?id=CVE-2026-138844","licence":"CVE Terms of Use","modified":"2026-11-30T13:25:30.613Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-138844","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-138844","licence":"Public domain","modified":"2026-11-30T14:17:39.980Z"}],"updatedAt":"2026-11-30T14:32:25.058Z","epss":{"score":0.00163,"percentile":0.05705,"date":"2026-12-01T12:00:22.000Z"}}