ata,scsi: libata-core: Do not leak memory for ata_port struct members
authorNiklas Cassel <cassel@kernel.org>
Sat, 29 Jun 2024 12:42:12 +0000 (14:42 +0200)
committerNiklas Cassel <cassel@kernel.org>
Sun, 30 Jun 2024 20:23:21 +0000 (22:23 +0200)
commitf6549f538fe0b2c389e1a7037f4e21039e25137a
tree00fa3e84ade238c1e4f871954cfe1c2a68afbc00
parent5d92c7c566dc76d96e0e19e481d926bbe6631c1e
ata,scsi: libata-core: Do not leak memory for ata_port struct members

libsas is currently not freeing all the struct ata_port struct members,
e.g. ncq_sense_buf for a driver supporting Command Duration Limits (CDL).

Add a function, ata_port_free(), that is used to free a ata_port,
including its struct members. It makes sense to keep the code related to
freeing a ata_port in its own function, which will also free all the
struct members of struct ata_port.

Fixes: 18bd7718b5c4 ("scsi: ata: libata: Handle completion of CDL commands using policy 0xD")
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20240629124210.181537-8-cassel@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
drivers/ata/libata-core.c
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_discover.c
include/linux/libata.h