{"id":"CVE-2022-50545","aliases":["CVE-2022-50545"],"related":[],"kind":"vulnerability","state":"published","title":"r6040: Fix kmemleak in probe and remove","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nr6040: Fix kmemleak in probe and remove\n\nThere is a memory leaks reported by kmemleak:\n\n  unreferenced object 0xffff888116111000 (size 2048):\n    comm \"modprobe\", pid 817, jiffies 4294759745 (age 76.502s)\n    hex dump (first 32 bytes):\n      00 c4 0a 04 81 88 ff ff 08 10 11 16 81 88 ff ff  ................\n      08 10 11 16 81 88 ff ff 00 00 00 00 00 00 00 00  ................\n    backtrace:\n      [<ffffffff815bcd82>] kmalloc_trace+0x22/0x60\n      [<ffffffff827e20ee>] phy_device_create+0x4e/0x90\n      [<ffffffff827e6072>] get_phy_device+0xd2/0x220\n      [<ffffffff827e7844>] mdiobus_scan+0xa4/0x2e0\n      [<ffffffff827e8be2>] __mdiobus_register+0x482/0x8b0\n      [<ffffffffa01f5d24>] r6040_init_one+0x714/0xd2c [r6040]\n      ...\n\nThe problem occurs in probe process as follows:\n  r6040_init_one:\n    mdiobus_register\n      mdiobus_scan    <- alloc and register phy_device,\n                         the reference count of phy_device is 3\n    r6040_mii_probe\n      phy_connect     <- connect to the first phy_device,\n                         so the reference count of the first\n                         phy_device is 4, others are 3\n    register_netdev   <- fault inject succeeded, goto error handling path\n\n    // error handling path\n    err_out_mdio_unregister:\n      mdiobus_unregister(lp->mii_bus);\n    err_out_mdio:\n      mdiobus_free(lp->mii_bus);    <- the reference count of the first\n                                       phy_device is 1, it is not released\n                                       and other phy_devices are released\n  // similarly, the remove process also has the same problem\n\nThe root cause is traced to the phy_device is not disconnected when\nremoves one r6040 device in r6040_remove_one() or on error handling path\nafter r6040_mii probed successfully. In r6040_mii_probe(), a net ethernet\ndevice is connected to the first PHY device of mii_bus, in order to\nnotify the connected driver when the link status changes, which is the\ndefault behavior of the PHY infrastructure to handle everything.\nTherefore the phy_device should be disconnected when removes one r6040\ndevice or on error handling path.\n\nFix it by adding phy_disconnect() when removes one r6040 device or on\nerror handling path after r6040_mii probed successfully.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nr6040: Fix kmemleak in probe and remove\n\nThere is a memory leaks reported by kmemleak:\n\n  unreferenced object 0xffff888116111000 (size 2048):\n    comm \"modprobe\", pid 817, jiffies 4294759745 (age 76.502s)\n    hex dump (first 32 bytes):\n      00 c4 0a 04 81 88 ff ff 08 10 11 16 81 88 ff ff  ................\n      08 10 11 16 81 88 ff ff 00 00 00 00 00 00 00 00  ................\n    backtrace:\n      [<ffffffff815bcd82>] kmalloc_trace+0x22/0x60\n      [<ffffffff827e20ee>] phy_device_create+0x4e/0x90\n      [<ffffffff827e6072>] get_phy_device+0xd2/0x220\n      [<ffffffff827e7844>] mdiobus_scan+0xa4/0x2e0\n      [<ffffffff827e8be2>] __mdiobus_register+0x482/0x8b0\n      [<ffffffffa01f5d24>] r6040_init_one+0x714/0xd2c [r6040]\n      ...\n\nThe problem occurs in probe process as follows:\n  r6040_init_one:\n    mdiobus_register\n      mdiobus_scan    <- alloc and register phy_device,\n                         the reference count of phy_device is 3\n    r6040_mii_probe\n      phy_connect     <- connect to the first phy_device,\n                         so the reference count of the first\n                         phy_device is 4, others are 3\n    register_netdev   <- fault inject succeeded, goto error handling path\n\n    // error handling path\n    err_out_mdio_unregister:\n      mdiobus_unregister(lp->mii_bus);\n    err_out_mdio:\n      mdiobus_free(lp->mii_bus);    <- the reference count of the first\n                                       phy_device is 1, it is not released\n                                       and other phy_devices are released\n  // similarly, the remove process also has the same problem\n\nThe root cause is traced to the phy_device is not disconnected when\nremoves one r6040 device in r6040_remove_one() or on error handling path\nafter r6040_mii probed successfully. In r6040_mii_probe(), a net ethernet\ndevice is connected to the first PHY device of mii_bus, in order to\nnotify the connected driver when the link status changes, which is the\ndefault behavior of the PHY infrastructure to handle everything.\nTherefore the phy_device should be disconnected when removes one r6040\ndevice or on error handling path.\n\nFix it by adding phy_disconnect() when removes one r6040 device or on\nerror handling path after r6040_mii probed successfully.","source":"cvelist"}],"published":"2025-10-07T15:21:09.288Z","modified":"2026-06-17T05:23:45.753Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","score":5.5,"rating":"MEDIUM"}],"cwes":["CWE-401"],"affected":[{"ranges":[{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"a04707f4596952049da05756c27398c34d9a1d36","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"b4448816e6a565e08236a6009c6bf48c6836cdfd","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"2ce242e1b9ad31c1f68496b3548e407a8cb2c07d","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"b0a61359026b57a287a48fbb4ba1d097023eca3e","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"3d5f83a62e8235d235534b3dc6f197d8a822c269","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"9b5b50329e2e966831a7237dd6949e7b5362a49a","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"ad2c8f25457ca9a81e7e958148cbc26600ce3071","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"5944c25c67de54e0aa53623e1e1af3bf8b16ed44","status":"affected"},{"type":"git","introduced":"3831861b4ad8fd0ad7110048eb3e155628799d2b","fixed":"7e43039a49c2da45edc1d9d7c9ede4003ab45a5f","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"2.6.36","status":"affected"},{"type":"semver","introduced":"0","fixed":"2.6.36","status":"unaffected"},{"type":"semver","introduced":"4.9.337","lastAffected":"4.9.*","status":"unaffected"},{"type":"semver","introduced":"4.14.303","lastAffected":"4.14.*","status":"unaffected"},{"type":"semver","introduced":"4.19.270","lastAffected":"4.19.*","status":"unaffected"},{"type":"semver","introduced":"5.4.229","lastAffected":"5.4.*","status":"unaffected"},{"type":"semver","introduced":"5.10.163","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.15.86","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"6.0.16","lastAffected":"6.0.*","status":"unaffected"},{"type":"semver","introduced":"6.1.2","lastAffected":"6.1.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.2","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"2.6.36","fixed":"4.9.337"},{"status":"affected","introduced":"4.10","fixed":"4.14.303"},{"status":"affected","introduced":"4.15","fixed":"4.19.270"},{"status":"affected","introduced":"4.20","fixed":"5.4.229"},{"status":"affected","introduced":"5.5","fixed":"5.10.163"},{"status":"affected","introduced":"5.11","fixed":"5.15.86"},{"status":"affected","introduced":"5.16","fixed":"6.0.16"},{"status":"affected","introduced":"6.1","fixed":"6.1.2"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/a04707f4596952049da05756c27398c34d9a1d36","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/b4448816e6a565e08236a6009c6bf48c6836cdfd","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/2ce242e1b9ad31c1f68496b3548e407a8cb2c07d","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/b0a61359026b57a287a48fbb4ba1d097023eca3e","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3d5f83a62e8235d235534b3dc6f197d8a822c269","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/9b5b50329e2e966831a7237dd6949e7b5362a49a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/ad2c8f25457ca9a81e7e958148cbc26600ce3071","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/5944c25c67de54e0aa53623e1e1af3bf8b16ed44","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/7e43039a49c2da45edc1d9d7c9ede4003ab45a5f","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-50545","url":"https://www.cve.org/CVERecord?id=CVE-2022-50545","licence":"CVE Terms of Use","modified":"2026-05-11T19:21:29.824Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-50545","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-50545","licence":"Public domain","modified":"2026-06-17T05:23:45.753Z"}],"updatedAt":"2026-11-25T22:58:21.265Z","epss":{"score":0.00213,"percentile":0.12342,"date":"2026-12-01T12:00:22.000Z"}}