From 756f173fb5fa90ec15222e80fb579288be7794fd Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 17 Nov 2011 17:59:48 -0800 Subject: [PATCH] [SCSI] libsas: fix leak of dev->sata_dev.identify_[packet_]device These are never freed in the nominal path. A domain_device has a different lifetime than a sas_rphy we need a dev->rphy independent way of identifying sata devices. Reviewed-by: Jack Wang Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- drivers/scsi/libsas/sas_discover.c | 6 ++++++ include/scsi/sas_ata.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 4e649306ef4..dc52b1fa218 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c @@ -30,6 +30,7 @@ #include #include +#include #include "../scsi_sas_internal.h" /* ---------- Basic task processing for discovery purposes ---------- */ @@ -231,6 +232,11 @@ void sas_free_device(struct kref *kref) if (dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV) kfree(dev->ex_dev.ex_phy); + if (dev_is_sata(dev)) { + kfree(dev->sata_dev.identify_device); + kfree(dev->sata_dev.identify_packet_device); + } + kfree(dev); } diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index 9c159f74c6d..7d5013f8653 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -32,7 +32,8 @@ static inline int dev_is_sata(struct domain_device *dev) { - return (dev->rphy->identify.target_port_protocols & SAS_PROTOCOL_SATA); + return dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM || + dev->dev_type == SATA_PM_PORT; } int sas_ata_init_host_and_port(struct domain_device *found_dev, -- 2.39.5