From patchwork Mon Aug 3 21:02:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 258020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F8DC433F7 for ; Mon, 3 Aug 2020 21:02:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9759722BED for ; Mon, 3 Aug 2020 21:02:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u+yB2Bpu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729052AbgHCVCr (ORCPT ); Mon, 3 Aug 2020 17:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729009AbgHCVCq (ORCPT ); Mon, 3 Aug 2020 17:02:46 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5467DC06174A for ; Mon, 3 Aug 2020 14:02:46 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id c19so784646wmd.1 for ; Mon, 03 Aug 2020 14:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9gWZ6B+baCzXX0ozkzR1zdM+vYtRLSawroM9ySFBAwM=; b=u+yB2Bpum/JKYUW90+kheoWWCIAGXNQ9B1SnZcfJU9K5mNjv6FRTfOKh1yXwUE4jb0 KqgVqDbF+jJm/8i94XVy9915zXB1AttwUuna0mTFK5JH3DPa0kjGDKsnMdPJmkz40MC+ 64jIcnTXedHoyf8fsxxZCnF6KL9fI71kO34GKo0QUm7tGaqldWtuqW3XGFm0KHcQj6Pq nnYtwEvbaRtw59UxtpPkNsy2MSfoXBJ+ZBuwLH//L+OyTEK678gM8SNrlnjH0LP+pckM LesBD6PtqhRiEbmGT8D5KWGrCS3Jlrd8OdvZGv6r76aYZZBERRU86RKehnMRFqKE/weY n2Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9gWZ6B+baCzXX0ozkzR1zdM+vYtRLSawroM9ySFBAwM=; b=Se7lOsbcyvlLN8OMU9n10JsCfEjNXdjhNyzroYSZgLim6gGZ4i3DBy0jBicyHalbde baRghas+QNj4Rmlsjq0kZURtoA4HOQPSn6DFM0QmBNIY8c9aAELU67J8V1H2YcjxfZZu 37NJyIZEG/CesEftYQY9xbI/5zsLYN3aRKghqyufSu02xaxgStNWeRUhpInsr8l8JNOP RiKRSFaTKXpueCfEEAhfmlgnW3PMpofAIZPi6jK5JTbpDJczM7cG/KAb9h7qx71UtJi6 /qoIk+SnqSlxRtqq1CGdiEQtIASHrlm1RECk9jXAFyaQINyfsanuZORISmVQtVzdis4Z HOgg== X-Gm-Message-State: AOAM533+vlJTRuFc3l5WOKgPyfJMeiu/74DThYqqY1f5KNyW4Tard8hv p2pWFTTJejmfon83CLpIgYyMvXJn X-Google-Smtp-Source: ABdhPJy+a9FSNCc6fey5XaIs6T8xmVyZrqmrKihWLqBlLK0pufA5ranMD0meK8vQbr0EcKuDVFxO0Q== X-Received: by 2002:a1c:a3c4:: with SMTP id m187mr867459wme.43.1596488564754; Mon, 03 Aug 2020 14:02:44 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id v15sm26649040wrm.23.2020.08.03.14.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 14:02:44 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: James Smart , Dick Kennedy Subject: [PATCH 4/8] lpfc: Fix oops when unloading driver while running mds diags Date: Mon, 3 Aug 2020 14:02:25 -0700 Message-Id: <20200803210229.23063-5-jsmart2021@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200803210229.23063-1-jsmart2021@gmail.com> References: <20200803210229.23063-1-jsmart2021@gmail.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org While mds diagnostic tests are running, if the driver is requested to be unloaded, oops or hangs are observed. The driver doesn't terminate the processing of diag frames when the unload is started. As such: oops may be seen for __lpfc_sli_release_iocbq_s4 because ring memory is referenced that was already freed; or hangs see in lpfc_nvme_wait_for_io_drain as ios no longer complete. If unloading, don't process diag frames. Just clean them up. Signed-off-by: Dick Kennedy Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_sli.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 8582b51b0613..4cd7ded656b7 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -13650,7 +13650,11 @@ lpfc_sli4_sp_handle_rcqe(struct lpfc_hba *phba, struct lpfc_rcqe *rcqe) fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { spin_unlock_irqrestore(&phba->hbalock, iflags); /* Handle MDS Loopback frames */ - lpfc_sli4_handle_mds_loopback(phba->pport, dma_buf); + if (!(phba->pport->load_flag & FC_UNLOADING)) + lpfc_sli4_handle_mds_loopback(phba->pport, + dma_buf); + else + lpfc_in_buf_free(phba, &dma_buf->dbuf); break; } @@ -18363,7 +18367,10 @@ lpfc_sli4_handle_received_buffer(struct lpfc_hba *phba, fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { vport = phba->pport; /* Handle MDS Loopback frames */ - lpfc_sli4_handle_mds_loopback(vport, dmabuf); + if (!(phba->pport->load_flag & FC_UNLOADING)) + lpfc_sli4_handle_mds_loopback(vport, dmabuf); + else + lpfc_in_buf_free(phba, &dmabuf->dbuf); return; } From patchwork Mon Aug 3 21:02:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 258021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69111C433F2 for ; Mon, 3 Aug 2020 21:02:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71B7622C9F for ; Mon, 3 Aug 2020 21:02:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ESC1C7FT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729167AbgHCVCs (ORCPT ); Mon, 3 Aug 2020 17:02:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729009AbgHCVCs (ORCPT ); Mon, 3 Aug 2020 17:02:48 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7CEC06174A for ; Mon, 3 Aug 2020 14:02:48 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id 3so895619wmi.1 for ; Mon, 03 Aug 2020 14:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DUkAJZkFY7n+19RfWv/Bd/8LC96PMNQVYdS2KsDgCIg=; b=ESC1C7FTRNDqP1vfHN38dSsRRXRx+6xxShmJhwMU+GkrLR2lr9WLIO9iBmq1hAvDt7 wpI0mGoVMRKjg7veF1CblPdctW9BjkTHgW1hcHHYeZHpvgj3Z02beOo3gqf0d7lPtoSf HgPNkmYpp7hcRU9yxFlUFYYCorbAKc7umX7W5K9/GokaoyTzT05OxqM/1gPqkvotObRE oHrZWFFdb0fWl4vWTeKrK1RE/TEoRlb4epQ3y88pVuYLclYLEphOHpjy0qOyEJQhFUZN huAxuwOC8E2RB57fDik4LxKJ1Ij9xe0UQ1VKtRU3FX7j/ZxOTMONiThm2McO2lz2Abmv jsNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DUkAJZkFY7n+19RfWv/Bd/8LC96PMNQVYdS2KsDgCIg=; b=MIiqeED59SxVeiGVEj56QGnTF3otPrFTHjTD4DAl5adfEz3VHZZmq5Yovyw4oACaFV GepZzJBVN6SjlhnLsuLUXQZHyVkXlEy8+q+ll10YkeuseuaxRsIzd5Vj/sI8xSTw6oPj s0/stszqHuTFvq4M9r2HEAH+cwnoNa2kWEiQuTaKSzPvf5pe6i6prFAdkQOPtzTEnf6j VDLFcGp6j+/FwQd9xNRHwN1+36jcdMElsk8cWYFlN/2dP9cS5yBIO+NsE2bl9N8qBtUz hVjvPce8eqUqFKF7Jb6VembuKg83P7Qi0ftMa+ngyTV8P+weDoCe/QZ6IfatFp/MD+Cx FK7w== X-Gm-Message-State: AOAM533cxbhoTJeVNUmmZb+kLQI5Bs4AKDPkzWKbZ9dMvADAqyJZEmwl YsEJ9bPpA+5kwnykl+iHPBZbYiKq X-Google-Smtp-Source: ABdhPJwVeP7kT3+VbUoc9+8MoqOt0eJnqL43FC9DnmH6LT3gxatQIu09BVfy0TkFSm1TK4P5rjaFAQ== X-Received: by 2002:a1c:c906:: with SMTP id f6mr967741wmb.5.1596488566603; Mon, 03 Aug 2020 14:02:46 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id v15sm26649040wrm.23.2020.08.03.14.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 14:02:45 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: James Smart , Dick Kennedy Subject: [PATCH 5/8] lpfc: Fix retry of PRLI when status indicates its unsupported Date: Mon, 3 Aug 2020 14:02:26 -0700 Message-Id: <20200803210229.23063-6-jsmart2021@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200803210229.23063-1-jsmart2021@gmail.com> References: <20200803210229.23063-1-jsmart2021@gmail.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org With port bounce/address swaps and timing between initiator GID queries vs remote port FC4 support registrations, the driver may be in a situation where it sends PRLIs for both FCP and NVME even though the target may not support one of the protocols. In this case, the remote port will reject the PRLI and usually indicate it does not support the request. However, the driver currently ignores the status of the failure and immediately retries the PRLI, which is pointless. In the case of this one remote port, the reception of the PRLI retry caused it to decide to send a LOGO. The LOGO restarted the process and the same results happened. It made the remote port undiscoverable to either protocol. Add logic to detect the non-support status and not attempt the retry of the PRLI. Signed-off-by: Dick Kennedy Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_els.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 85d4e4000c25..48dc63f22cca 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -3937,10 +3937,14 @@ lpfc_els_retry(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, case LSRJT_UNABLE_TPC: /* The driver has a VALID PLOGI but the rport has * rejected the PRLI - can't do it now. Delay - * for 1 second and try again - don't care about - * the explanation. + * for 1 second and try again. + * + * However, if explanation is REQ_UNSUPPORTED there's + * no point to retry PRLI. */ - if (cmd == ELS_CMD_PRLI || cmd == ELS_CMD_NVMEPRLI) { + if ((cmd == ELS_CMD_PRLI || cmd == ELS_CMD_NVMEPRLI) && + stat.un.b.lsRjtRsnCodeExp != + LSEXP_REQ_UNSUPPORTED) { delay = 1000; maxretry = lpfc_max_els_tries + 1; retry = 1; From patchwork Mon Aug 3 21:02:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 258022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D5B2C433F4 for ; Mon, 3 Aug 2020 21:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DDA922CA1 for ; Mon, 3 Aug 2020 21:02:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j3PDCXOl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729157AbgHCVCv (ORCPT ); Mon, 3 Aug 2020 17:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729009AbgHCVCu (ORCPT ); Mon, 3 Aug 2020 17:02:50 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D847C06174A for ; Mon, 3 Aug 2020 14:02:50 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id g8so799199wmk.3 for ; Mon, 03 Aug 2020 14:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u55z9bcq+J6rq7uqGinlGbUrA/EMY41lFFoVd349Cn0=; b=j3PDCXOl0scRLh0fhSeBi8Dzhp5xi13a3xCUJUBKVKhvoDJ4JlFOZ9G7OThWwmx4mb C8TByN3azLKdV4Ep3erGMR1p3G12k00MF9gpvw3e0beTPbled9L/jI3DAoir+Dyhmh9T SB/BEMfA9wLCC59bZpwGj9dbiVusdM8sai8zwOhtnO/ma1Xofxq+ArBDShg3Xftk6864 lmI27J1SUuIccBKhTv9dUnb01pL7uT1wOCPoaxp9c83/HiWvQ7FnCx5EwPXxGD2FEObx gD6c3c1ftqBeDCQ1dWX/CzTOs4dMNeCQFNdXC8ikOFncLIK8MqH5FrGSXvaq9/d4BnrR A/qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u55z9bcq+J6rq7uqGinlGbUrA/EMY41lFFoVd349Cn0=; b=VtEyCxL0+yUAVVDwDYJz8Q4f3C1R8kRdVgRvndcq15SeS44BC1U13xlRy4kfxJGH5a OxLuX9htghqf4JoP51LIN47Fu+dvVQehbZWa95oQfS3VfV03Jd8TT+Py99TW+zn0wu1a 536wAt9rVdsKk3S8gagym3DwZ4bD/z+eWgWz6sTJF9/nVKg5/hu5pH4rrRBO0tnf2S+O pnHnW8NW70wS8IoEwGaJjUQnLHg4A5dZMaHAWSrtX9snepqlqKQVtT+gZ71kphiU3tj1 gafZbDaZwE9MvwaX9bpXgd2ep8hr/jx5ynBAPQn0hh3ZF/9QVz/z2EiG0we9a17GZW/e 4wfw== X-Gm-Message-State: AOAM533eFT8hgjlMPfLY7eOk+4nyJvAd3vZwuiePig4/94WKEGWeaCJP XGHP9+8cObgDNu/Zg8ZZ5/rTUh3j X-Google-Smtp-Source: ABdhPJzFq/UMls9soQo037wHbONW4LUSklK/pxeSWXjfJwcUr6wPu+rOoSZfJ+hnMQ14t2+fEnFFjA== X-Received: by 2002:a7b:c084:: with SMTP id r4mr888485wmh.23.1596488568630; Mon, 03 Aug 2020 14:02:48 -0700 (PDT) Received: from localhost.localdomain.localdomain ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id v15sm26649040wrm.23.2020.08.03.14.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 14:02:48 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: James Smart , Dick Kennedy Subject: [PATCH 6/8] lpfc: Fix validation of bsg reply lengths Date: Mon, 3 Aug 2020 14:02:27 -0700 Message-Id: <20200803210229.23063-7-jsmart2021@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200803210229.23063-1-jsmart2021@gmail.com> References: <20200803210229.23063-1-jsmart2021@gmail.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There are a couple of code areas which validate sufficient reply buffer length, but the checks are using the request elements rather than the reply elements. Rework to validate using the reply structures. Signed-off-by: Dick Kennedy Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_bsg.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c index 1d88fedaf3f0..6f9d648a9b9c 100644 --- a/drivers/scsi/lpfc/lpfc_bsg.c +++ b/drivers/scsi/lpfc/lpfc_bsg.c @@ -2494,13 +2494,12 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_job *job) diag_status_reply = (struct diag_status *) bsg_reply->reply_data.vendor_reply.vendor_rsp; - if (job->reply_len < - sizeof(struct fc_bsg_request) + sizeof(struct diag_status)) { + if (job->reply_len < sizeof(*bsg_reply) + sizeof(*diag_status_reply)) { lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, "3012 Received Run link diag test reply " "below minimum size (%d): reply_len:%d\n", - (int)(sizeof(struct fc_bsg_request) + - sizeof(struct diag_status)), + (int)(sizeof(*bsg_reply) + + sizeof(*diag_status_reply)), job->reply_len); rc = -EINVAL; goto job_error; @@ -3418,8 +3417,7 @@ lpfc_bsg_get_dfc_rev(struct bsg_job *job) event_reply = (struct get_mgmt_rev_reply *) bsg_reply->reply_data.vendor_reply.vendor_rsp; - if (job->reply_len < - sizeof(struct fc_bsg_request) + sizeof(struct get_mgmt_rev_reply)) { + if (job->reply_len < sizeof(*bsg_reply) + sizeof(*event_reply)) { lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, "2741 Received GET_DFC_REV reply below " "minimum size\n"); @@ -5202,8 +5200,8 @@ lpfc_menlo_cmd(struct bsg_job *job) goto no_dd_data; } - if (job->reply_len < - sizeof(struct fc_bsg_request) + sizeof(struct menlo_response)) { + if (job->reply_len < sizeof(*bsg_reply) + + sizeof(struct menlo_response)) { lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, "2785 Received MENLO_CMD reply below " "minimum size\n"); @@ -5359,9 +5357,7 @@ lpfc_forced_link_speed(struct bsg_job *job) forced_reply = (struct forced_link_speed_support_reply *) bsg_reply->reply_data.vendor_reply.vendor_rsp; - if (job->reply_len < - sizeof(struct fc_bsg_request) + - sizeof(struct forced_link_speed_support_reply)) { + if (job->reply_len < sizeof(*bsg_reply) + sizeof(*forced_reply)) { lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, "0049 Received FORCED_LINK_SPEED reply below " "minimum size\n"); @@ -5715,8 +5711,7 @@ lpfc_get_trunk_info(struct bsg_job *job) event_reply = (struct lpfc_trunk_info *) bsg_reply->reply_data.vendor_reply.vendor_rsp; - if (job->reply_len < - sizeof(struct fc_bsg_request) + sizeof(struct lpfc_trunk_info)) { + if (job->reply_len < sizeof(*bsg_reply) + sizeof(*event_reply)) { lpfc_printf_log(phba, KERN_WARNING, LOG_LIBDFC, "2728 Received GET TRUNK _INFO reply below " "minimum size\n");