summaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2009-08-18 15:43:06 +0200
committerJames Bottomley <James.Bottomley@suse.de>2009-09-05 08:49:04 -0500
commita67417ab7eeff45bba55666c0e1083260f3624ee (patch)
tree7f52c070bc9eeb7f5bdbb7f35e26e6ddb2624772 /drivers/s390
parentcdf69bb91b0ef14f0e0a987a4430764e6c290644 (diff)
downloadop-kernel-dev-a67417ab7eeff45bba55666c0e1083260f3624ee.zip
op-kernel-dev-a67417ab7eeff45bba55666c0e1083260f3624ee.tar.gz
[SCSI] zfcp: invalid usage after free of port resources
In certain error scenarios ports, rports are getting attached, validated and removed from the systems environment. Depending on the layer this occurs asynchronously. This patch fixes the few races which existed and ensures all references and cross references are cleared at the time they're invalid. In addition fc transports actions are only scheduled when required. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c7
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c6
2 files changed, 9 insertions, 4 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 2ccbd18..fa2460b 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -672,12 +672,15 @@ err_out:
*/
void zfcp_port_dequeue(struct zfcp_port *port)
{
- wait_event(port->remove_wq, atomic_read(&port->refcount) == 0);
write_lock_irq(&zfcp_data.config_lock);
list_del(&port->list);
write_unlock_irq(&zfcp_data.config_lock);
- if (port->rport)
+ if (port->rport) {
port->rport->dd_data = NULL;
+ port->rport = NULL;
+ }
+ wait_event(port->remove_wq, atomic_read(&port->refcount) == 0);
+ cancel_work_sync(&port->rport_work); /* usually not necessary */
zfcp_adapter_put(port->adapter);
sysfs_remove_group(&port->sysfs_device.kobj, &zfcp_sysfs_port_attrs);
device_unregister(&port->sysfs_device);
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 6925a17..54a7a74 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -582,8 +582,10 @@ void zfcp_scsi_schedule_rport_block(struct zfcp_port *port)
zfcp_port_get(port);
port->rport_task = RPORT_DEL;
- if (!queue_work(zfcp_data.work_queue, &port->rport_work))
- zfcp_port_put(port);
+ if (port->rport && queue_work(zfcp_data.work_queue, &port->rport_work))
+ return;
+
+ zfcp_port_put(port);
}
void zfcp_scsi_schedule_rports_block(struct zfcp_adapter *adapter)
OpenPOWER on IntegriCloud