From patchwork Thu Jan 24 05:25:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ming.lu.mlu@gmail.com X-Patchwork-Id: 10778329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 225421390 for ; Thu, 24 Jan 2019 05:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07DAE2C3AD for ; Thu, 24 Jan 2019 05:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFD812D34E; Thu, 24 Jan 2019 05:25:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 985D52D035 for ; Thu, 24 Jan 2019 05:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726025AbfAXFZt (ORCPT ); Thu, 24 Jan 2019 00:25:49 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42601 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725986AbfAXFZt (ORCPT ); Thu, 24 Jan 2019 00:25:49 -0500 Received: by mail-pg1-f193.google.com with SMTP id d72so2153400pga.9 for ; Wed, 23 Jan 2019 21:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to; bh=ts4glARYl81Lmg4BEsyOjC0XyTHvp3T+WkP91OvKYBo=; b=by4oUhywLO22KUnUU/TbXGp6NNfgCztyQNFk29KZ8TFiBOcp9UKfswnEx7IIVIIbR9 gYxdnUm+ukc4Lk/f/KGnEgZimUIREuevh1xNu6cxYSU8JzIgMdIeFd/ExflGuIWZREeE 8DbiNLdohX66uhGszo2Eg6CvovFtQaX5yMwnvRzY0W1DAuBsZrjS42TK4U6mVAU67VeZ B4AmZ/iz833jaYpOJ421N2rGeUqdGIBTHI0fbmfksgzF8dnyPXtg5owiESUrtjLckS0X OedmSTacldoX6GaIwedJSGILLaBZJkGMlSC4orurHReuAUV0IFM/djVjLJAai0MN9Suf DVkw== 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:reply-to; bh=ts4glARYl81Lmg4BEsyOjC0XyTHvp3T+WkP91OvKYBo=; b=Q7V7gVb/eqBAZlEKU9XUmANVDiQI9ZX10EhwPBzq8alinR2aDVFzP0ox9/2VAmWfev Wwk9r0Em4vB29qmxnz+1WJsnz0/MlhqMQNG8lI1ZhpiDHVYjoSotgGFzcSNVdsY257qF tBbZGhJwVZCkqekP4srLMDAFULZITL3pn0jmLBgaHulhvwQdk8tyfRkOG0j9PxdecBEP H+sffF4vDm2pQWJX0TMClSAPgB9I6owQqETrOp6Lx4r2KlNbKIjKdb8QvFiP2yIkAkOM VVZDxw4gHB35HuvaxlCY8w9UE9bzxfFEeEzH5Vt0cjZJKIkFSSRqoHrXOqoIucRIYTob /vog== X-Gm-Message-State: AJcUukeIwn4WCLO1SwwotMZCOrWwAzERWyxMunt80hh+wGHUHrO4oUjl VvGO6JEMO/j9BO9peshctvE= X-Google-Smtp-Source: ALg8bN5Pjf3W1eu8BWrmwVDdFbHMkQsiTl25ydGl/swP+r1squvNpzNsW7pblpQNG9wutXA/gTeVGQ== X-Received: by 2002:aa7:8286:: with SMTP id s6mr4958847pfm.63.1548307549173; Wed, 23 Jan 2019 21:25:49 -0800 (PST) Received: from mingl-Latitude-E5470.citrite.net ([103.14.252.249]) by smtp.gmail.com with ESMTPSA id s79sm39864534pgs.50.2019.01.23.21.25.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 21:25:48 -0800 (PST) From: ming.lu.mlu@gmail.com To: jth@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: Ming Lu Subject: [PATCH] libfc free skb when receiving invalid flogi resp Date: Thu, 24 Jan 2019 13:25:42 +0800 Message-Id: <20190124052542.12167-1-ming.lu.mlu@gmail.com> X-Mailer: git-send-email 2.17.1 Reply-To: ming.lu@citrix.com 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: Ming Lu The issue to be fixed in this commit is when libfc found it received a invalid FLOGI response from FC switch, it would return without freeing the fc frame, which is just the skb data. This would cause memory leak if FC switch keeps sending invalid FLOGI responses. This fix is just to make it execute `fc_frame_free(fp)` before returning from function `fc_lport_flogi_resp`. Signed-off-by: Ming Lu Reviewed-by: Hannes Reinecke --- drivers/scsi/libfc/fc_lport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index be83590ed955..ff943f477d6f 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c @@ -1726,14 +1726,14 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, fc_frame_payload_op(fp) != ELS_LS_ACC) { FC_LPORT_DBG(lport, "FLOGI not accepted or bad response\n"); fc_lport_error(lport, fp); - goto err; + goto out; } flp = fc_frame_payload_get(fp, sizeof(*flp)); if (!flp) { FC_LPORT_DBG(lport, "FLOGI bad response\n"); fc_lport_error(lport, fp); - goto err; + goto out; } mfs = ntohs(flp->fl_csp.sp_bb_data) & @@ -1743,7 +1743,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, " "lport->mfs:%hu\n", mfs, lport->mfs); fc_lport_error(lport, fp); - goto err; + goto out; } if (mfs <= lport->mfs) {