libata: update port initialisation for SAS call in
Subsystems (4)
James Bottomley
maintainerPATCH 1/1 libata: update port initialisation for SAS call in
The current port initialisation is skating on thin ice ... it doesn't fill in the device and link backlinks, and it doesn't add the sdev. Currently, this is all fine because they're never used, but it's a NULL deref waiting to happen, so fill them all in.
Signed-off-by James Bottomley <[email protected]>
----
I need to use this in the following patch to plumb in the queue depth setting, so I'll take this through the scsi trees with the appropriate acks.
James
drivers/ata/libata-scsi.c +4 -1
@@ -3634,12 +3648,15 @@ EXPORT_SYMBOL_GPL(ata_sas_port_stop);* Zero on success, non-zero on error. */ -int ata_sas_port_init (struct ata_port *ap) +int ata_sas_port_init (struct ata_port *ap,struct scsi_device *sdev) {int rc = ap->ops->port_start (ap);if (!rc) { ap->print_id = ata_print_id++; + ap->link.device->sdev = sdev; + ap->link.device->link = &ap->link; + ap->link.ap = ap; rc =ata_bus_probe (ap); }
drivers/scsi/ipr.c +1 -1
@@ -3694,7 +3694,7 @@ static int ipr_ata_slave_alloc(struct scsi_device *sdev)if (sdev->sdev_target) sata_port = sdev->sdev_target->hostdata;if (sata_port) - rc =ata_sas_port_init (sata_port->ap); + rc =ata_sas_port_init (sata_port->ap, sdev);if (rc)ipr_slave_destroy (sdev);
drivers/scsi/libsas/sas_expander.c +0 -0
drivers/scsi/libsas/sas_scsi_host.c +1 -1
@@ -1048,7 +1062,7 @@ int sas_slave_alloc(struct scsi_device *scsi_dev)struct domain_device *dev =sdev_to_domain_dev (scsi_dev);if (dev_is_sata (dev)) -return ata_sas_port_init (dev->sata_dev.ap); +return ata_sas_port_init (dev->sata_dev.ap, scsi_dev);return 0 ; }
include/linux/libata.h +1 -1
@@ -815,7 +815,7 @@ extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnextern void ata_sas_port_destroy (struct ata_port *);extern struct ata_port *ata_sas_port_alloc (struct ata_host *,struct ata_port_info *,struct Scsi_Host *); -extern int ata_sas_port_init (struct ata_port *); +extern int ata_sas_port_init (struct ata_port *,struct scsi_device *);extern int ata_sas_port_start (struct ata_port *ap);extern void ata_sas_port_stop (struct ata_port *ap);extern int ata_sas_slave_configure (struct scsi_device *,struct ata_port *);