From patchwork Wed Dec 20 06:56:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 322A46019C for ; Wed, 20 Dec 2017 06:56:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26E3C29649 for ; Wed, 20 Dec 2017 06:56:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B7962964F; Wed, 20 Dec 2017 06:56:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0818529649 for ; Wed, 20 Dec 2017 06:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932345AbdLTG4z (ORCPT ); Wed, 20 Dec 2017 01:56:55 -0500 Received: from mail-co1nam03on0050.outbound.protection.outlook.com ([104.47.40.50]:2481 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932295AbdLTG4x (ORCPT ); Wed, 20 Dec 2017 01:56:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tsDoniqrylyY4gFVVwxoc4hi+bHJt5EPqjVFmRQLumg=; b=PIXB6h7sDo8n5z9j/zD6ppQkq3z6nHlLx1Vwc4gyojrfV0ruqGU+kHi9SUnLmEK6AFZjSqtQO9AaPraSmQDtrrlXvtdFfpjEB2yPZDtKp2usVc8MrUQY/7ePyO6QPbOQnhEMaRt8SBvqm4WBarlngJ92LWWpHwtA2z+8A0y+kq4= Received: from DM5PR07CA0046.namprd07.prod.outlook.com (10.168.109.32) by SN1PR0701MB1952.namprd07.prod.outlook.com (10.163.131.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 06:56:50 +0000 Received: from BN1AFFO11FD026.protection.gbl (2a01:111:f400:7c10::102) by DM5PR07CA0046.outlook.office365.com (2603:10b6:3:16::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Wed, 20 Dec 2017 06:56:50 +0000 Authentication-Results: spf=permerror (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD026.mail.protection.outlook.com (10.58.52.86) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 06:56:36 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 19 Dec 2017 22:56:45 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id vBK6uj2r021550; Tue, 19 Dec 2017 22:56:45 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6ujTi021549; Tue, 19 Dec 2017 22:56:45 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 01/43] qla2xxx: Fix stale memory access for name pointer Date: Tue, 19 Dec 2017 22:56:02 -0800 Message-ID: <20171220065644.21511-2-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com> References: <20171220065644.21511-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(39380400002)(39860400002)(376002)(396003)(2980300002)(448002)(189003)(199004)(4326008)(86362001)(85326001)(69596002)(59450400001)(51416003)(1076002)(36756003)(316002)(2950100002)(6666003)(42186006)(50466002)(48376002)(478600001)(2906002)(110136005)(72206003)(54906003)(16586007)(87636003)(8936002)(5660300001)(76176011)(81166006)(305945005)(80596001)(47776003)(8676002)(356003)(50226002)(81156014)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0701MB1952; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD026; 1:DHLR41xvAfoaJ0kNHNfT8vK7c8g86I48aWi/5cFZkEZSLseZGrax1UVG+SxV9lc+VwhRdpG59cA3TMYDA4Vzf2KtOe7vflzkcmU976xpQYcbeivePMcD15Tf2shXITHq X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1c2054c-4d91-4366-7a30-08d54776d09a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:SN1PR0701MB1952; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1952; 3:R9eaJWrX6edCwzyZr8UjThPA12mH120v/Ch/OHultOaAf9idZHfHjZFf6cRTV28zvkoLwxG/TdFu1H9T71SuKPD89PMItv38IBkUe/4HqSdxrQngTZe7UIEr3qz1dZnLG6l63D66If8vBNP6bQ5eUBHPAFbUhxwSMaX8jqdPFSRBFq2jCqb5k3Hd22Nip5z69XE+pQ0D8y295OlsCumbHE38rz3IzbQ6+cTY0lXfKeJCr2QiR50Xrdynzl/PkkfG+jUKZfjjfQFzAR4sIGIOp1dpdnmkYm76h/tIW1PSJ+aotb4K1+lDlF+iM6fjhXxWeUh4WgP8qpMti/25697hVBkiRDbRV1wRUiVErPV+Lu8=; 25:ejF9Pj2v9u3OkjSm+tOnbhGvxtSzggsM1SfPMSxgSQTon9cFEPvgWYhhpN3PrHoqM/a2hve70RT2mBimqudXJHeKPCM4yhwWC4kmJvOwq8VgSkIa8UESDj8sjvwIetfgJyR+LmhUKFJmJd1lQpCeL9PcU8iXP+tW4+g12ENIPw8Ynm6HbzCWOfeK8uEdddB2CddEkglKQUV8MHlzq2OKK87QTBI/jXk+klCTAcLobYOhvZkcUub8rbYFGkE6UQwMiOBz+aRWzSryeii5nAYqGOeNV1LPID4igaC91vUEe/iYBXX3JhA/w7lgpQv5Ye/uR/dKFfxnE8cOEDCbJFdljw== X-MS-TrafficTypeDiagnostic: SN1PR0701MB1952: X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1952; 31:EEPWfFmZ/7jJFxogcs6F4hqE4+fUrww5BTcKJTPC1CjKSt6tvkjD6IaYvz7wKeVJt737XwN7vo51c22EcNO5kSUoMZCqxXi7eUokB629NkAWtNdYWpcWLPxHhtNP+84gQP1E9OfxwXJCs3JT6F/Sn9GtzRDOrJGNMG6VUDQHS6gef05gcPd/aQFuOXdV/V1m7JB/gTjS6hqjwZRHgI6e78TImCS1hjVoJuI7VLbK5Bo=; 20:6l1txeU9i8mUAOZKcSw56x3oSnwnr1QsdEE/pLC65pTyCcSZTpKCsQtmByMhaL+jW9xDb3PDBK1qwbSgiSdnjq7tPr8wZdtCTzuJll7OOoUc9nEBrV3WXBQ32OVh73zVL0TKd4hS3+eT4xmx5gnWlrFobMyG38IFVrRaYfbpGGT9g6/PEf10de+TeQIuvDjZEkSK3i+OwOngcSBkt/R0IcgWRqub+duUfrK0bAv2WZ3PLvzj4lkULtFMpNqYE5lBYlKWF/CRE6cxZFVnN59XzW74ObuqYrHTGjbJ+0eHhBiFgAX0lNh3Na2zmXb8s34cVM9e/Q2BAK/tEw87QQDe2xdnNG3el9ITxELDhhXdc2DtM+hnZNFrBTcvnMlFEPixqlyjLI7PUG0gebOhvJdK5v0zt4mmBig793vxtogAn0ZWWrqzEmVJeaz4GgNfIajQDdlhKDzuDm1zq3FbupUoDePGCwlgpCxlBbvGu8pEYTpYkzhbIpXOP8UE2wm/GNtX X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(3231023)(93006095)(93001095)(10201501046)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:SN1PR0701MB1952; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN1PR0701MB1952; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1952; 4:+FZJfe/fdDQveAD4/foRhYolxV25pSTim22h/Yc8DJfvRtpDcxYrwoo4PWdXhtsYWwjv2qK/NLta9Y8EGk/tms0q5Yp0lp1OjihNPv3laepffLCG/mxYYPjKqi67p0MFlyFrXQzJKT2NL8dzxyLtSWiJC40uwf5gRaXGF8+3Yj8/X0iB8oe2qKvvOwUurlsqUVYfzpb80CmYomKD6WFTGRVdIw8lw231QGqz0CxzkQi1o/cwzQw+UjUoUm1In6vvbaRraKNNSu5tR+Pj+NWqCQ== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0701MB1952; 23:qujZ1A1B+BG/9L1CR4WiXKE3RUZp2ZuznBkpiKo?= =?us-ascii?Q?pNd0Chl9S2iFGCg5SXT9xz+qAcDjYCspMl/qRqM0F+Cwex0MuNPthMSLuqiS?= =?us-ascii?Q?9t/YBRnS1p7JARXtKK61Gye/vL1bBJr3s+ZZqYgwbimJiFBfseX35fEBpl0M?= =?us-ascii?Q?RnWHvwDj4U7OIf/FeuYb6YaMNBaAQPPquPbGA/tzayWAiXVTHWbjr2vjBHt1?= =?us-ascii?Q?XlqRNnQIbw5XADjDI1+xKU9K6fs8Ps0GT2iwPqRrdIm1hPzqa9POUKKtCz6E?= =?us-ascii?Q?9K3ftfn/tDrmijcP2197s2SnVlaIRK2a8aDmVTbBraxJ93rSQem9WFVAwPCY?= =?us-ascii?Q?722wOO5eIkjr1Nf4srhmfzsddbtTllz6GJCEqczv4CsOYcYFLweCv/ebZCXi?= =?us-ascii?Q?H7w02FzmxVeM4QJ7XXzgUCpxp8+tda5MvDkl+gjijPPq2alwZVZEZgsRlucT?= =?us-ascii?Q?YfB0JD5zHNvkUF0SvVDeGoqDTf5UY9lSeJQzPlm+VhtQfu7iNebOVxbLE8YG?= =?us-ascii?Q?vrWdZhufK/H8O3cj4r6wXHbQJgsK8HhG8dZHaMuSturju9cVL5CTSUGKbDyw?= =?us-ascii?Q?O4NdYXn7ZeBIn2X58xNrTwhk/Ht8orBOwMz42X4hahT7tRax3JA79i9k0jQS?= =?us-ascii?Q?VncC0G5X9oa1b5d+O8UHbiFj6po/RT2U3AecEwoz21WL6ZPo6f+oGe9PxmK0?= =?us-ascii?Q?VTKs8LiZAwurzSFIaL27bWWnOc64j6eCUMfyTDomzU5PFJmuP6YAKf2QeEXG?= =?us-ascii?Q?Xg/WOLqtIBh5ipB0XcF4IQCTJ8ThUF1KKu6gPeKfADwWYJfVDXhEMF/ia9vY?= =?us-ascii?Q?AnsuaX6ztezH8FR9e0vz2dkfiNfsXjuBgCwCKzEHBUN/li6GLdOCq6pjKdr8?= =?us-ascii?Q?5/E3onRx9P80CzOcd2842B5oeth40fHnaDVaym529HIQIi8wN/KWFrx0UNsE?= =?us-ascii?Q?cdhMOYBjcRmbX7hCzPMNhw28gytl/w6IN8vYr2FRngdOBcAvIVZIAAaxoPXA?= =?us-ascii?Q?UOm3q4Sno8GUp8dn8SXflQHd/?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB1952; 6:ayUK4UmQ3aX/JN0QkL0007HjgV+MbV22R1Ov452P0eodNsCQd29dECPYOwUqTOFz3grUsIIarHMffGQJItxddbcqwdTOq6JdqVf6+TIkE9t/m2FGG+8yguWKC4VOhe4dBJevZMGhbme692iO0ajyEtPWB5bs81K2Q5PhMlcoV1pmsQwguJj3AE+se1/GKesGqLBJYlcxOqb2Ez9Faa25QAccYifjatg0k2PIcqRBvbYqz+CVLMHZTR1BgqQqNo+5pw2g5gpcUtkWACz+T8DYGf6x/NnBv3PW22AAHFebdYZcsmrInB1vDEDhECXHwXI7ATFjcbmMITaq+y7kRhkMB2cLmFN4tu+JQqnMIsPkxvk=; 5:phjl/tTs0rpl4B3WeR7fAJdasOgb1fl+Eg7R7+rqrGeOENTntiIEzqVfnVOPTB3nJ//xG83/MR/56J6as87ddMKUDSDjTjE0AIef1lEoSrUnvkWjRdc7CT3Tvrljkhn4Y3FFAeSPtD81ZKUPyj+munlz6l1G2BRt5XHRu8XvUlI=; 24:YHfdLxyGxcGoB1Elw+d1BwH6zvKzB9EW7IbLw6jPfNAHb+t4fjatyb+AeJjqBSEXPiePv4rOXB4GXQGzEu8Fs3aS9scUFT/vDBuSHQqEL3A=; 7:BBL4DfO+FvurXpMlKRFSL5m7zqDfZNHc2cpvBVY+dVLdNdmhWc3nGq8326MhUdDkspsCkuuzltQAqd2MjkdyMtfBZFCFqqMK+PXEpWzuNxeOlEF8mjvJKl5AO0Cw6RcSVjWudS1WvUPbRSxsqNOVeRvxbBdYLkml1rEwQK83Tdy1iAo7rsFDo/YEtaUtmOddd0TxNEMJZXngTGJISP41e4fVLv1n4aH/8Yb7Wgj1qo3+RYrbV2lYNlEIux0JOjts SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:56:36.9923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1c2054c-4d91-4366-7a30-08d54776d09a X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0701MB1952 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran Name pointer for sp describing each command is assigned with stack frame's memory. The stack frame could eventually be re-use, where name pointer access can get get garbage. This patch designates static memory for name pointer to fix this problem. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_bsg.c | 7 +++--- drivers/scsi/qla2xxx/qla_def.h | 36 +++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_gbl.h | 1 + drivers/scsi/qla2xxx/qla_gs.c | 51 ++++++++++++++++++++++++++++++++++++--- drivers/scsi/qla2xxx/qla_init.c | 16 ++++++------ drivers/scsi/qla2xxx/qla_iocb.c | 4 +-- drivers/scsi/qla2xxx/qla_mbx.c | 5 ++-- drivers/scsi/qla2xxx/qla_mr.c | 2 +- drivers/scsi/qla2xxx/qla_nvme.c | 4 +-- drivers/scsi/qla2xxx/qla_target.c | 2 +- 10 files changed, 105 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index e3ac7078d2aa..3fc3ae9abb39 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -376,7 +376,8 @@ qla2x00_process_els(struct bsg_job *bsg_job) SRB_ELS_CMD_RPT : SRB_ELS_CMD_HST); sp->name = (bsg_request->msgcode == FC_BSG_RPT_ELS ? - "bsg_els_rpt" : "bsg_els_hst"); + sp_to_str(SPCN_BSG_RPT) : sp_to_str(SPCN_BSG_HST)); + sp->u.bsg_job = bsg_job; sp->free = qla2x00_bsg_sp_free; sp->done = qla2x00_bsg_job_done; @@ -522,7 +523,7 @@ qla2x00_process_ct(struct bsg_job *bsg_job) } sp->type = SRB_CT_CMD; - sp->name = "bsg_ct"; + sp->name = sp_to_str(SPCN_BSG_CT); sp->iocbs = qla24xx_calc_ct_iocbs(req_sg_cnt + rsp_sg_cnt); sp->u.bsg_job = bsg_job; sp->free = qla2x00_bsg_sp_free; @@ -2028,7 +2029,7 @@ qlafx00_mgmt_cmd(struct bsg_job *bsg_job) fcport->loop_id = piocb_rqst->dataword; sp->type = SRB_FXIOCB_BCMD; - sp->name = "bsg_fx_mgmt"; + sp->name = sp_to_str(SPCN_BSG_FX_MGMT); sp->iocbs = qla24xx_calc_ct_iocbs(req_sg_cnt + rsp_sg_cnt); sp->u.bsg_job = bsg_job; sp->free = qla2x00_bsg_sp_free; diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 93ff92e2363f..4d65fd973a12 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -478,6 +478,42 @@ struct srb_iocb { void (*timeout)(void *); }; +enum { + SPCN_UNKNOWN, + SPCN_GIDPN, + SPCN_GPSC, + SPCN_GPNID, + SPCN_GPNFT, + SPCN_GNNID, + SPCN_GFPNID, + SPCN_LOGIN, + SPCN_LOGOUT, + SPCN_ADISC, + SPCN_GNLIST, + SPCN_GPDB, + SPCN_TMF, + SPCN_ABORT, + SPCN_NACK, + SPCN_BSG_RPT, + SPCN_BSG_HST, + SPCN_BSG_CT, + SPCN_BSG_FX_MGMT, + SPCN_ELS_DCMD, + SPCN_FXDISC, + SPCN_GIDLIST, + SPCN_STATS, + SPCN_MB_GPDB, + SPCN_GFFID, + SPCN_PRLI, + SPCN_NVME_LS, + SPCN_NVME_CMD, +}; + +struct sp_name { + uint16_t cmd; + const char *str; +}; + /* Values for srb_ctx type */ #define SRB_LOGIN_CMD 1 #define SRB_LOGOUT_CMD 2 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index fa115c7433e5..bf907386f177 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -647,6 +647,7 @@ int qla24xx_async_gpsc(scsi_qla_host_t *, fc_port_t *); int qla2x00_mgmt_svr_login(scsi_qla_host_t *); void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea); int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport); +const char *sp_to_str(uint16_t); /* * Global Function Prototypes in qla_attr.c source file. */ diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 07fe17a986b0..7e88e8289157 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -15,6 +15,49 @@ static int qla2x00_sns_gnn_id(scsi_qla_host_t *, sw_info_t *); static int qla2x00_sns_rft_id(scsi_qla_host_t *); static int qla2x00_sns_rnn_id(scsi_qla_host_t *); +struct sp_name sp_str[] = { + { SPCN_UNKNOWN, "unknown" }, + { SPCN_GIDPN, "gidpn" }, + { SPCN_GPSC, "gpsc" }, + { SPCN_GPNID, "gpnid" }, + { SPCN_GPNFT, "gpnft" }, + { SPCN_GNNID, "gnnid" }, + { SPCN_GFPNID, "gfpnid" }, + { SPCN_GFFID, "gffid" }, + { SPCN_LOGIN, "login" }, + { SPCN_LOGOUT, "logout" }, + { SPCN_ADISC, "adisc" }, + { SPCN_GNLIST, "gnlist" }, + { SPCN_GPDB, "gpdb" }, + { SPCN_TMF, "tmf" }, + { SPCN_ABORT, "abort" }, + { SPCN_NACK, "nack" }, + { SPCN_BSG_RPT, "bsg_els_rpt" }, + { SPCN_BSG_HST, "bsg_els_hst" }, + { SPCN_BSG_CT, "bsg_ct" }, + { SPCN_BSG_FX_MGMT, "bsg_fx_mgmt" }, + { SPCN_ELS_DCMD, "ELS_DCMD" }, + { SPCN_FXDISC, "fxdisc" }, + { SPCN_PRLI, "prli" }, + { SPCN_NVME_LS, "nvme_ls" }, + { SPCN_NVME_CMD, "nvme_cmd" }, +}; + +const char *sp_to_str(uint16_t cmd) +{ + int i; + struct sp_name *e; + + for (i = 1; i < ARRAY_SIZE(sp_str); i++) { + e = sp_str + i; + if (cmd == e->cmd) + return e->str; + } + + return sp_str[0].str; +} + + /** * qla2x00_prep_ms_iocb() - Prepare common MS/CT IOCB fields for SNS CT query. * @ha: HA context @@ -2931,7 +2974,7 @@ int qla24xx_async_gidpn(scsi_qla_host_t *vha, fc_port_t *fcport) goto done; sp->type = SRB_CT_PTHRU_CMD; - sp->name = "gidpn"; + sp->name = sp_to_str(SPCN_GIDPN); sp->gen1 = fcport->rscn_gen; sp->gen2 = fcport->login_gen; @@ -3091,7 +3134,7 @@ int qla24xx_async_gpsc(scsi_qla_host_t *vha, fc_port_t *fcport) goto done; sp->type = SRB_CT_PTHRU_CMD; - sp->name = "gpsc"; + sp->name = sp_to_str(SPCN_GPSC); sp->gen1 = fcport->rscn_gen; sp->gen2 = fcport->login_gen; @@ -3398,7 +3441,7 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id) goto done; sp->type = SRB_CT_PTHRU_CMD; - sp->name = "gpnid"; + sp->name = sp_to_str(SPCN_GPNID); sp->u.iocb_cmd.u.ctarg.id = *id; sp->gen1 = 0; qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); @@ -3550,7 +3593,7 @@ int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport) fcport->flags |= FCF_ASYNC_SENT; sp->type = SRB_CT_PTHRU_CMD; - sp->name = "gffid"; + sp->name = sp_to_str(SPCN_GFFID); sp->gen1 = fcport->rscn_gen; sp->gen2 = fcport->login_gen; diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 58663df38627..7fa71170d6ff 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -186,7 +186,7 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, fcport->logout_completed = 0; sp->type = SRB_LOGIN_CMD; - sp->name = "login"; + sp->name = sp_to_str(SPCN_LOGIN); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); lio = &sp->u.iocb_cmd; @@ -248,7 +248,7 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport) goto done; sp->type = SRB_LOGOUT_CMD; - sp->name = "logout"; + sp->name = sp_to_str(SPCN_LOGOUT); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); lio = &sp->u.iocb_cmd; @@ -300,7 +300,7 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport, goto done; sp->type = SRB_ADISC_CMD; - sp->name = "adisc"; + sp->name = sp_to_str(SPCN_ADISC); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); lio = &sp->u.iocb_cmd; @@ -583,7 +583,7 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport) if (!sp) goto done; sp->type = SRB_MB_IOCB; - sp->name = "gnlist"; + sp->name = sp_to_str(SPCN_GNLIST); sp->gen1 = fcport->rscn_gen; sp->gen2 = fcport->login_gen; @@ -741,7 +741,7 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t *fcport) fcport->logout_completed = 0; sp->type = SRB_PRLI_CMD; - sp->name = "prli"; + sp->name = sp_to_str(SPCN_PRLI); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); lio = &sp->u.iocb_cmd; @@ -807,7 +807,7 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt) goto done; sp->type = SRB_MB_IOCB; - sp->name = "gpdb"; + sp->name = sp_to_str(SPCN_GPDB); sp->gen1 = fcport->rscn_gen; sp->gen2 = fcport->login_gen; qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); @@ -1298,7 +1298,7 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun, tm_iocb = &sp->u.iocb_cmd; sp->type = SRB_TM_CMD; - sp->name = "tmf"; + sp->name = sp_to_str(SPCN_TMF); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)); tm_iocb->u.tmf.flags = flags; tm_iocb->u.tmf.lun = lun; @@ -1376,7 +1376,7 @@ qla24xx_async_abort_cmd(srb_t *cmd_sp) abt_iocb = &sp->u.iocb_cmd; sp->type = SRB_ABT_CMD; - sp->name = "abort"; + sp->name = sp_to_str(SPCN_ABORT); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)); abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; sp->done = qla24xx_abort_sp_done; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 8ea59586f4f1..b5d1423f933d 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2454,7 +2454,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode, fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa); sp->type = SRB_ELS_DCMD; - sp->name = "ELS_DCMD"; + sp->name = sp_to_str(SPCN_ELS_DCMD); sp->fcport = fcport; qla2x00_init_timer(sp, ELS_DCMD_TIMEOUT); elsio->timeout = qla2x00_els_dcmd_iocb_timeout; @@ -2652,7 +2652,7 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode, "Enter: PLOGI portid=%06x\n", fcport->d_id.b24); sp->type = SRB_ELS_DCMD; - sp->name = "ELS_DCMD"; + sp->name = sp_to_str(SPCN_ELS_DCMD); sp->fcport = fcport; qla2x00_init_timer(sp, ELS_DCMD_TIMEOUT); elsio->timeout = qla2x00_els_dcmd2_iocb_timeout; diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index e2b5fa47bb57..f5cbdaeaea1f 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -14,6 +14,7 @@ static struct mb_cmd_name { uint16_t cmd; const char *str; } mb_str[] = { + {0, "unknown mb"}, {MBC_GET_PORT_DATABASE, "GPDB"}, {MBC_GET_ID_LIST, "GIDList"}, {MBC_GET_LINK_PRIV_STATS, "Stats"}, @@ -24,12 +25,12 @@ static const char *mb_to_str(uint16_t cmd) int i; struct mb_cmd_name *e; - for (i = 0; i < ARRAY_SIZE(mb_str); i++) { + for (i = 1; i < ARRAY_SIZE(mb_str); i++) { e = mb_str + i; if (cmd == e->cmd) return e->str; } - return "unknown"; + return mb_str[0].str; } static struct rom_cmd { diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c index d5da3981cefe..9184f6016fe0 100644 --- a/drivers/scsi/qla2xxx/qla_mr.c +++ b/drivers/scsi/qla2xxx/qla_mr.c @@ -1820,7 +1820,7 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type) goto done; sp->type = SRB_FXIOCB_DCMD; - sp->name = "fxdisc"; + sp->name = sp_to_str(SPCN_FXDISC); qla2x00_init_timer(sp, FXDISC_TIMEOUT); fdisc = &sp->u.iocb_cmd; diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 6b33a1f24f56..d398d45f937f 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -239,7 +239,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, return rval; sp->type = SRB_NVME_LS; - sp->name = "nvme_ls"; + sp->name = sp_to_str(SPCN_NVME_LS); sp->done = qla_nvme_sp_ls_done; atomic_set(&sp->ref_count, 1); nvme = &sp->u.iocb_cmd; @@ -526,7 +526,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, init_waitqueue_head(&sp->nvme_ls_waitq); priv->sp = sp; sp->type = SRB_NVME_CMD; - sp->name = "nvme_cmd"; + sp->name = sp_to_str(SPCN_NVME_CMD); sp->done = qla_nvme_sp_done; sp->qpair = qpair; nvme = &sp->u.iocb_cmd; diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 067bcc57a9ad..fcfdbe1420cd 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -661,7 +661,7 @@ int qla24xx_async_notify_ack(scsi_qla_host_t *vha, fc_port_t *fcport, goto done; sp->type = type; - sp->name = "nack"; + sp->name = sp_to_str(SPCN_NACK); qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)+2);