spi: spi-sprd-adi: Fix double free in probe error path
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
spi: spi-sprd-adi: Fix double free in probe error path
The driver currently uses spi_alloc_host() to allocate the controller but registers it using devm_spi_register_controller().
If devm_register_restart_handler() fails, the code jumps to the put_ctlr label and calls spi_controller_put(). However, since the controller was registered via a devm function, the device core will automatically call spi_controller_put() again when the probe fails. This results in a double-free of the spi_controller structure.
Fix this by switching to devm_spi_alloc_host() and removing the manual spi_controller_put() call.
From the CVE record · Linux
The Linux kernel’s spi-sprd-adi driver can free a SPI controller twice if restart-handler registration fails during device probe. The input does not establish whether an attacker can trigger this condition, or specify access or authentication requirements.
Engineers running Linux kernels that include the spi-sprd-adi driver should check whether their kernel contains the fix; affected versions were not provided.