From: Andrew Vasquez Date: Thu, 14 Jul 2005 23:40:04 +0000 (-0700) Subject: [PATCH] qla2xxx: Correct handling of fc_remote_port_add() failure case. X-Git-Tag: v2.6.12.4~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50eb930a92e7070f6a110789245398bff4061059;p=thirdparty%2Fkernel%2Fstable.git [PATCH] qla2xxx: Correct handling of fc_remote_port_add() failure case. 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 Signed-off-by: Andrew Vasquez Signed-off-by: Chris Wright Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 0387005fcb6df..4d624881e2bc4 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1914,9 +1914,11 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) 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;