phy: mdio: fix memory leak
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 46abc02175b3c246dd5141d878f565a8725060c9 · < 0d2dd40a7be61b89a7c99dae8ee96389d27b413a| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
phy: mdio: fix memory leak
Syzbot reported memory leak in MDIO bus interface, the problem was in wrong state logic.
MDIOBUS_ALLOCATED indicates 2 states: 1. Bus is only allocated 2. Bus allocated and __mdiobus_register() fails, but device_register() was called
In case of device_register() has been called we should call put_device() to correctly free the memory allocated for this device, but mdiobus_free() calls just kfree(dev) in case of MDIOBUS_ALLOCATED state
To avoid this behaviour we need to set bus->state to MDIOBUS_UNREGISTERED _before_ calling device_register(), because put_device() should be called even in case of device_register() failure.
From the CVE record · Linux
The Linux kernel's MDIO bus interface can leak memory when device registration fails because the cleanup path does not release the device correctly. The input does not specify how an attacker could trigger the failure or whether access or user interaction is required.
Engineers running the Linux kernel should check their versions; the affected versions are not specified.