[02/13] qla2xxx: Correct handling of fc_remote_port_add() failure case.

From: Chris Wright
Date: Wed Aug 03 2005 - 01:55:14 EST


-stable review patch. If anyone has any objections, please let us know.

------------------

Correct handling of fc_remote_port_add() failure case.

Immediately return if fc_remote_port_add() fails to allocate
resources for the rport. Original code would result in NULL
pointer dereference upon failure.

Reported-by: Michael Reed <mdr@xxxxxxx>

Signed-off-by: Andrew Vasquez <andrew.vasquez@xxxxxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
drivers/scsi/qla2xxx/qla_init.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletion(-)

--- linux-2.6.12.3.orig/drivers/scsi/qla2xxx/qla_init.c 2005-07-28 11:17:01.000000000 -0700
+++ linux-2.6.12.3/drivers/scsi/qla2xxx/qla_init.c 2005-07-28 11:17:08.000000000 -0700
@@ -1914,9 +1914,11 @@
rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;

fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids);
- if (!rport)
+ if (!rport) {
qla_printk(KERN_WARNING, ha,
"Unable to allocate fc remote port!\n");
+ return;
+ }

if (rport->scsi_target_id != -1 && rport->scsi_target_id < MAX_TARGETS)
fcport->os_target_id = rport->scsi_target_id;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/