Skip to content

Commit 756f173

Browse files
djbwJames Bottomley
authored andcommitted
[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 <jack_wang@usish.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 735f7d2 commit 756f173

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎drivers/scsi/libsas/sas_discover.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <scsi/scsi_transport.h>
3232
#include <scsi/scsi_transport_sas.h>
33+
#include <scsi/sas_ata.h>
3334
#include "../scsi_sas_internal.h"
3435

3536
/* ---------- Basic task processing for discovery purposes ---------- */
@@ -231,6 +232,11 @@ void sas_free_device(struct kref *kref)
231232
if (dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV)
232233
kfree(dev->ex_dev.ex_phy);
233234

235+
if (dev_is_sata(dev)) {
236+
kfree(dev->sata_dev.identify_device);
237+
kfree(dev->sata_dev.identify_packet_device);
238+
}
239+
234240
kfree(dev);
235241
}
236242

‎include/scsi/sas_ata.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
static inline int dev_is_sata(struct domain_device *dev)
3434
{
35-
return (dev->rphy->identify.target_port_protocols & SAS_PROTOCOL_SATA);
35+
return dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM ||
36+
dev->dev_type == SATA_PM_PORT;
3637
}
3738

3839
int sas_ata_init_host_and_port(struct domain_device *found_dev,

0 commit comments

Comments
 (0)