Commit 5e456a9b authored by Dave Boutcher's avatar Dave Boutcher Committed by James Bottomley

[PATCH] ibmvscsi: fix dangling pointer reference

This code has been problematic for a while and still contained a leg
where free_event_struct was called....followed by a reference to the
event_struct.  Restructure to make the code cleaner and fix the
dangling pointer reference.
Signed-off-by: default avatarDave Boutcher <boutcher@us.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent bb87af13
...@@ -87,7 +87,7 @@ static int max_channel = 3; ...@@ -87,7 +87,7 @@ static int max_channel = 3;
static int init_timeout = 5; static int init_timeout = 5;
static int max_requests = 50; static int max_requests = 50;
#define IBMVSCSI_VERSION "1.5.3" #define IBMVSCSI_VERSION "1.5.4"
MODULE_DESCRIPTION("IBM Virtual SCSI"); MODULE_DESCRIPTION("IBM Virtual SCSI");
MODULE_AUTHOR("Dave Boutcher"); MODULE_AUTHOR("Dave Boutcher");
...@@ -467,7 +467,7 @@ static int map_data_for_srp_cmd(struct scsi_cmnd *cmd, ...@@ -467,7 +467,7 @@ static int map_data_for_srp_cmd(struct scsi_cmnd *cmd,
static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
struct ibmvscsi_host_data *hostdata) struct ibmvscsi_host_data *hostdata)
{ {
struct scsi_cmnd *cmnd = evt_struct->cmnd; struct scsi_cmnd *cmnd;
u64 *crq_as_u64 = (u64 *) &evt_struct->crq; u64 *crq_as_u64 = (u64 *) &evt_struct->crq;
int rc; int rc;
...@@ -479,23 +479,16 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, ...@@ -479,23 +479,16 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) && if ((evt_struct->crq.format == VIOSRP_SRP_FORMAT) &&
(atomic_dec_if_positive(&hostdata->request_limit) < 0)) { (atomic_dec_if_positive(&hostdata->request_limit) < 0)) {
/* See if the adapter is disabled */ /* See if the adapter is disabled */
if (atomic_read(&hostdata->request_limit) < 0) { if (atomic_read(&hostdata->request_limit) < 0)
if (cmnd) goto send_error;
cmnd->result = DID_ERROR << 16;
if (evt_struct->cmnd_done) printk(KERN_WARNING
evt_struct->cmnd_done(cmnd); "ibmvscsi: Warning, request_limit exceeded\n");
unmap_cmd_data(&evt_struct->iu.srp.cmd,
hostdata->dev);
free_event_struct(&hostdata->pool, evt_struct);
return 0;
} else {
printk("ibmvscsi: Warning, request_limit exceeded\n");
unmap_cmd_data(&evt_struct->iu.srp.cmd, unmap_cmd_data(&evt_struct->iu.srp.cmd,
hostdata->dev); hostdata->dev);
free_event_struct(&hostdata->pool, evt_struct); free_event_struct(&hostdata->pool, evt_struct);
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
} }
}
/* Copy the IU into the transfer area */ /* Copy the IU into the transfer area */
*evt_struct->xfer_iu = evt_struct->iu; *evt_struct->xfer_iu = evt_struct->iu;
...@@ -511,17 +504,23 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct, ...@@ -511,17 +504,23 @@ static int ibmvscsi_send_srp_event(struct srp_event_struct *evt_struct,
ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) { ibmvscsi_send_crq(hostdata, crq_as_u64[0], crq_as_u64[1])) != 0) {
list_del(&evt_struct->list); list_del(&evt_struct->list);
cmnd = evt_struct->cmnd;
printk(KERN_ERR "ibmvscsi: failed to send event struct rc %d\n", printk(KERN_ERR "ibmvscsi: failed to send event struct rc %d\n",
rc); rc);
goto send_error;
}
return 0;
send_error:
unmap_cmd_data(&evt_struct->iu.srp.cmd, hostdata->dev); unmap_cmd_data(&evt_struct->iu.srp.cmd, hostdata->dev);
free_event_struct(&hostdata->pool, evt_struct);
if (cmnd) if ((cmnd = evt_struct->cmnd) != NULL) {
cmnd->result = DID_ERROR << 16; cmnd->result = DID_ERROR << 16;
if (evt_struct->cmnd_done)
evt_struct->cmnd_done(cmnd); evt_struct->cmnd_done(cmnd);
} } else if (evt_struct->done)
evt_struct->done(evt_struct);
free_event_struct(&hostdata->pool, evt_struct);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment