forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/scsi/bfa/bfa_fcs_lport.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
34 * Copyright (c) 2014- QLogic Corporation.
....@@ -5,15 +6,6 @@
56 * www.qlogic.com
67 *
78 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
8
- *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms of the GNU General Public License (GPL) Version 2 as
11
- * published by the Free Software Foundation
12
- *
13
- * This program is distributed in the hope that it will be useful, but
14
- * WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * General Public License for more details.
179 */
1810
1911 #include "bfad_drv.h"
....@@ -1291,7 +1283,7 @@
12911283 n2n_port->reply_oxid = 0;
12921284 }
12931285
1294
-void
1286
+static void
12951287 bfa_fcport_get_loop_attr(struct bfa_fcs_lport_s *port)
12961288 {
12971289 int i = 0, j = 0, bit = 0, alpa_bit = 0;
....@@ -1416,7 +1408,7 @@
14161408 u32 resid_len,
14171409 struct fchs_s *rsp_fchs);
14181410 static void bfa_fcs_lport_fdmi_timeout(void *arg);
1419
-static u16 bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s *fdmi,
1411
+static int bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s *fdmi,
14201412 u8 *pyld);
14211413 static u16 bfa_fcs_lport_fdmi_build_rprt_pyld(struct bfa_fcs_lport_fdmi_s *fdmi,
14221414 u8 *pyld);
....@@ -1895,6 +1887,8 @@
18951887 bfa_fcs_lport_fdmi_build_rhba_pyld(fdmi,
18961888 (u8 *) ((struct ct_hdr_s *) pyld
18971889 + 1));
1890
+ if (attr_len < 0)
1891
+ return;
18981892
18991893 bfa_fcxp_send(fcxp, NULL, port->fabric->vf_id, port->lp_tag, BFA_FALSE,
19001894 FC_CLASS_3, (len + attr_len), &fchs,
....@@ -1904,17 +1898,20 @@
19041898 bfa_sm_send_event(fdmi, FDMISM_EVENT_RHBA_SENT);
19051899 }
19061900
1907
-static u16
1901
+static int
19081902 bfa_fcs_lport_fdmi_build_rhba_pyld(struct bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
19091903 {
19101904 struct bfa_fcs_lport_s *port = fdmi->ms->port;
1911
- struct bfa_fcs_fdmi_hba_attr_s hba_attr;
1912
- struct bfa_fcs_fdmi_hba_attr_s *fcs_hba_attr = &hba_attr;
1905
+ struct bfa_fcs_fdmi_hba_attr_s *fcs_hba_attr;
19131906 struct fdmi_rhba_s *rhba = (struct fdmi_rhba_s *) pyld;
19141907 struct fdmi_attr_s *attr;
1908
+ int len;
19151909 u8 *curr_ptr;
1916
- u16 len, count;
1917
- u16 templen;
1910
+ u16 templen, count;
1911
+
1912
+ fcs_hba_attr = kzalloc(sizeof(*fcs_hba_attr), GFP_KERNEL);
1913
+ if (!fcs_hba_attr)
1914
+ return -ENOMEM;
19181915
19191916 /*
19201917 * get hba attributes
....@@ -2156,6 +2153,9 @@
21562153 len += ((sizeof(attr->type) + sizeof(attr->len)) * count);
21572154
21582155 rhba->hba_attr_blk.attr_count = cpu_to_be32(count);
2156
+
2157
+ kfree(fcs_hba_attr);
2158
+
21592159 return len;
21602160 }
21612161
....@@ -4366,7 +4366,7 @@
43664366 bfa_sm_set_state(ns,
43674367 bfa_fcs_lport_ns_sm_sending_gid_ft);
43684368 bfa_fcs_lport_ns_send_gid_ft(ns, NULL);
4369
- };
4369
+ }
43704370 break;
43714371
43724372 default:
....@@ -6430,9 +6430,7 @@
64306430 switch (event) {
64316431 case BFA_FCS_VPORT_SM_OFFLINE:
64326432 bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
6433
- /*
6434
- * !!! fall through !!!
6435
- */
6433
+ fallthrough;
64366434
64376435 case BFA_FCS_VPORT_SM_RSP_OK:
64386436 case BFA_FCS_VPORT_SM_RSP_ERROR:
....@@ -6458,9 +6456,7 @@
64586456 switch (event) {
64596457 case BFA_FCS_VPORT_SM_OFFLINE:
64606458 bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
6461
- /*
6462
- * !!! fall through !!!
6463
- */
6459
+ fallthrough;
64646460
64656461 case BFA_FCS_VPORT_SM_RSP_OK:
64666462 case BFA_FCS_VPORT_SM_RSP_ERROR: