Skip to content

Commit 22a0853

Browse files
Vijaya Mohan GuvvaJames Bottomley
authored andcommitted
[SCSI] bfa: Fix crash when symb name set for offline vport
This patch fixes a crash when tried setting symbolic name for an offline vport through sysfs. Crash is due to uninitialized pointer lport->ns, which gets initialized only on linkup (port online). Signed-off-by: Vijaya Mohan Guvva <vmohan@brocade.com> Cc: stable@vger.kernel.org Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent a1470c7 commit 22a0853

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎drivers/scsi/bfa/bfa_fcs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn,
296296
struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
297297
u16 vf_id, wwn_t lpwwn);
298298

299+
void bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port, char *symname);
299300
void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
300301
struct bfa_lport_info_s *port_info);
301302
void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,

‎drivers/scsi/bfa/bfa_fcs_lport.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,17 @@ bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
10971097
bfa_sm_send_event(lport, BFA_FCS_PORT_SM_CREATE);
10981098
}
10991099

1100+
void
1101+
bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port,
1102+
char *symname)
1103+
{
1104+
strcpy(port->port_cfg.sym_name.symname, symname);
1105+
1106+
if (bfa_sm_cmp_state(port, bfa_fcs_lport_sm_online))
1107+
bfa_fcs_lport_ns_util_send_rspn_id(
1108+
BFA_FCS_GET_NS_FROM_PORT(port), NULL);
1109+
}
1110+
11001111
/*
11011112
* fcs_lport_api
11021113
*/
@@ -5140,9 +5151,6 @@ bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg, struct bfa_fcxp_s *fcxp_alloced)
51405151
u8 *psymbl = &symbl[0];
51415152
int len;
51425153

5143-
if (!bfa_sm_cmp_state(port, bfa_fcs_lport_sm_online))
5144-
return;
5145-
51465154
/* Avoid sending RSPN in the following states. */
51475155
if (bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_offline) ||
51485156
bfa_sm_cmp_state(ns, bfa_fcs_lport_ns_sm_plogi_sending) ||

‎drivers/scsi/bfa/bfad_attr.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,8 @@ bfad_im_vport_set_symbolic_name(struct fc_vport *fc_vport)
593593
return;
594594

595595
spin_lock_irqsave(&bfad->bfad_lock, flags);
596-
if (strlen(sym_name) > 0) {
597-
strcpy(fcs_vport->lport.port_cfg.sym_name.symname, sym_name);
598-
bfa_fcs_lport_ns_util_send_rspn_id(
599-
BFA_FCS_GET_NS_FROM_PORT((&fcs_vport->lport)), NULL);
600-
}
596+
if (strlen(sym_name) > 0)
597+
bfa_fcs_lport_set_symname(&fcs_vport->lport, sym_name);
601598
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
602599
}
603600

0 commit comments

Comments
 (0)