Skip to content

Commit

Permalink
[SCSI] libsas: fix leak of dev->sata_dev.identify_[packet_]device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
djbw authored and James Bottomley committed Feb 19, 2012
1 parent 735f7d2 commit 756f173
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions drivers/scsi/libsas/sas_discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_sas.h>
#include <scsi/sas_ata.h>
#include "../scsi_sas_internal.h"

/* ---------- Basic task processing for discovery purposes ---------- */
Expand Down Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion include/scsi/sas_ata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 756f173

Please sign in to comment.