Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2285450iof; Wed, 8 Jun 2022 01:26:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxpzZAYU1Ccw7vaHP4u4hCyUVhvD6Lr4aCi4omhSUEcthtGtGEKUnsIlJOwAdQdEyQYhkX X-Received: by 2002:a05:6a00:2244:b0:51b:b974:4294 with SMTP id i4-20020a056a00224400b0051bb9744294mr33628277pfu.67.1654676764471; Wed, 08 Jun 2022 01:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676764; cv=none; d=google.com; s=arc-20160816; b=X/z0McRmXyWNdX2RAilR0FpgD04F3thwgDuQ7f+dWQrZEXn7j9XkEkDJ5y2a0UKOky N30RxW0Ms5e3A74XJe1DmbigvID1+vjTyhSJGBZYdxX6oigbz1BbTqLuj6ggK7pXECim V4NdKoBnaR4LO1ldBAbedltRbQNo81POywVq7HlFggh3HrG+cPNLVZTScm81GF0EMayZ PLP24lYATx55dX0pkuFOqhO52HCbnE+eqwif8Cjajmfsd6U7i1zsw/IcNRUKyAfe3f1O LRUR2Ahq/pxV2uoHK914yfU9zN4dy9kvSBdIg5dZYxdci0wIqjVf0sAFkavBfOo6Jhx6 M2IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CP27pomiIuCjIfBaoxGK1TNGum3qZb8DK8Fpytb+4l4=; b=j8rbwuirp+bdbRD40R8A85LZ4dGMyxBqBaZuQcgkpgyzBT/2zeNpw5KE9PoXFanlN8 i4bECZ4Mv/snBNqyNJO02Itk1xa6DyNCiQWFKAUapAcJ8Xx+agoeu1mBDgqoL0YUkaQz vfD5/uLl9ly7rhmUfwjfGXLUE4kWJBl8c0UJXaZv4sx8fh60EDRaQkyPug6MnhRm0xlJ jNGiRy79LH5Z8V8NwXuax4e2+FbF2Gs7wsTEsmDkmBi+W0JxAiQK1a2fBV6PRzZ6ktRr LsupdMijU6jLTH4IaLfAykVSG5ffCpX1Kk/85K0dpKZD3SgxBWqd5kfApLPrK++MWFEm QpVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tn8IMquU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m10-20020a170902768a00b00161946a7108si23964337pll.161.2022.06.08.01.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tn8IMquU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B14E41DBBDC; Wed, 8 Jun 2022 00:56:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384165AbiFGWOA (ORCPT + 99 others); Tue, 7 Jun 2022 18:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379951AbiFGVLU (ORCPT ); Tue, 7 Jun 2022 17:11:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C717521682F; Tue, 7 Jun 2022 11:52:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 76063B82018; Tue, 7 Jun 2022 18:52:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8210C385A2; Tue, 7 Jun 2022 18:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627953; bh=uBJsSL0dyV/euH9wSsRXymgQdHcQOPUzRb7f6NJVMeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tn8IMquUjPrnpP12iVQcejOIoiZrimE3RgUMTsRU9zW0UYw6yATsOWYJfsWwDtHXA c6E1uTukmmkt3ar/gGqQlGULVGYJpQQDbCOtgbarlShNDUIBq4c7Rd9Eirje4EaEaE iI+P8r5ckxTyrDzlcSuuZ+CSzZqlOA89Cl1l5cgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Justin Tee , James Smart , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.18 112/879] scsi: lpfc: Fix resource leak in lpfc_sli4_send_seq_to_ulp() Date: Tue, 7 Jun 2022 18:53:50 +0200 Message-Id: <20220607165005.949318007@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Smart [ Upstream commit 646db1a560f44236b7278b822ca99a1d3b6ea72c ] If no handler is found in lpfc_complete_unsol_iocb() to match the rctl of a received frame, the frame is dropped and resources are leaked. Fix by returning resources when discarding an unhandled frame type. Update lpfc_fc_frame_check() handling of NOP basic link service. Link: https://lore.kernel.org/r/20220426181419.9154-1-jsmart2021@gmail.com Co-developed-by: Justin Tee Signed-off-by: Justin Tee Signed-off-by: James Smart Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_sli.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 09a45f8ecf3f..a174e06bd96e 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -18124,7 +18124,6 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) case FC_RCTL_ELS_REP: /* extended link services reply */ case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */ case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */ - case FC_RCTL_BA_NOP: /* basic link service NOP */ case FC_RCTL_BA_ABTS: /* basic link service abort */ case FC_RCTL_BA_RMC: /* remove connection */ case FC_RCTL_BA_ACC: /* basic accept */ @@ -18145,6 +18144,7 @@ lpfc_fc_frame_check(struct lpfc_hba *phba, struct fc_frame_header *fc_hdr) fc_vft_hdr = (struct fc_vft_header *)fc_hdr; fc_hdr = &((struct fc_frame_header *)fc_vft_hdr)[1]; return lpfc_fc_frame_check(phba, fc_hdr); + case FC_RCTL_BA_NOP: /* basic link service NOP */ default: goto drop; } @@ -18959,12 +18959,14 @@ lpfc_sli4_send_seq_to_ulp(struct lpfc_vport *vport, if (!lpfc_complete_unsol_iocb(phba, phba->sli4_hba.els_wq->pring, iocbq, fc_hdr->fh_r_ctl, - fc_hdr->fh_type)) + fc_hdr->fh_type)) { lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT, "2540 Ring %d handler: unexpected Rctl " "x%x Type x%x received\n", LPFC_ELS_RING, fc_hdr->fh_r_ctl, fc_hdr->fh_type); + lpfc_in_buf_free(phba, &seq_dmabuf->dbuf); + } /* Free iocb created in lpfc_prep_seq */ list_for_each_entry_safe(curr_iocb, next_iocb, -- 2.35.1