Commit 284b75a
ata: libata: Fix memory leak for error path in ata_host_alloc()
In ata_host_alloc(), if devres_alloc() fails to allocate the device host
resource data pointer, the already allocated ata_host structure is not
freed before returning from the function. This results in a potential
memory leak.
Call kfree(host) before jumping to the error handling path to ensure
that the ata_host structure is properly freed if devres_alloc() fails.
Fixes: 2623c7a ("libata: add refcounting to ata_host")
Cc: [email protected]
Signed-off-by: Zheng Qixing <[email protected]>
Reviewed-by: Yu Kuai <[email protected]>
Signed-off-by: Damien Le Moal <[email protected]>1 parent d4bc0a2 commit 284b75a
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5593 | 5593 | | |
5594 | 5594 | | |
5595 | 5595 | | |
5596 | | - | |
| 5596 | + | |
| 5597 | + | |
5597 | 5598 | | |
| 5599 | + | |
5598 | 5600 | | |
5599 | 5601 | | |
5600 | 5602 | | |
| |||
0 commit comments