From patchwork Mon Oct 30 14:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 159776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2272879vqb; Mon, 30 Oct 2023 07:50:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUyjdvwR1yke0jTND/lby/O+gXpG5p/8phuwAvJuA5PY/gesoclNayiryMCVZOe2Kd5IOM X-Received: by 2002:a17:903:84b:b0:1c1:dbd6:9bf6 with SMTP id ks11-20020a170903084b00b001c1dbd69bf6mr8839037plb.41.1698677403817; Mon, 30 Oct 2023 07:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698677403; cv=none; d=google.com; s=arc-20160816; b=Ztgjyvw4tHW4DEybP9h6wCQuhY+I2dvnYQgc15HFk5AFoTF/+GXrOPvFKYCuS1Rjty MwOjIMcgovCnNNJ8JUUn/WAXxs8g+Kwashd+akJhfFPvy9rZjX8SQ8cGwYLdTcg/W5hz qS16i9t5abl0BMbaBc3fZTza3RUwZF5rcLI+DF8TLWTlh9nCjKC1HcmbW0ZNg5dfuw8Z Li6t89LovssVo98aoLghJYMrlbyzWvUoBjaG7zBONZMnPf5zIYmujvZGrF4jgp3wzHfL eF9RM6GISsBTOl2C1sc8RWfQo2+Uy7sFhGnO3iHxiZLIPe3P6V8xunssr3kTX15y3l3s +Tjw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=cE6pCOkG8VB8NCmHUswVDdYmjB1x/ugVETT8yljrntY=; fh=SXPRxVGed35u/qlqQ4PpR8jxHSJDYghCgIedl6vnXI4=; b=C9qiX51vKNKnThWdoiZR8MjOLwPYzCU4SwikU9nZi4p2kSlHsIEbDu5PLPxubmV4/m jene59IYW0etFIM4mo9zi9VqLI0a1UoFyP7bN5aAW73FilHeJ//q79liPZ/ziEFbWgJL yBMdO08UCDTpCS5mszViGCSJReiEId/wZyt/9com/WuJA1tg9W5fvySD4s9Da5uku37n sHP/NjNSjsNH/rKeqqRKEpKG/2z54lf04LzXwLrBOpT/QquOM9pbMc1NzXWzPUHRhY+P MoaVd5hmPN1AzsFEzv1IkPUl2OOfPzbGTagliq3rhYePsrBPUQBDxOXXygSKsvgFCrnH BpcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Er2l+6Na; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001c9e29d5d8asi5315836plh.112.2023.10.30.07.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 07:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Er2l+6Na; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 28FEA804B00E; Mon, 30 Oct 2023 07:50:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233525AbjJ3Otj (ORCPT + 32 others); Mon, 30 Oct 2023 10:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231919AbjJ3Oti (ORCPT ); Mon, 30 Oct 2023 10:49:38 -0400 Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D43ECC for ; Mon, 30 Oct 2023 07:49:33 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id xTa5qOlxecvbdxTa5q48rW; Mon, 30 Oct 2023 15:49:31 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698677371; bh=cE6pCOkG8VB8NCmHUswVDdYmjB1x/ugVETT8yljrntY=; h=From:To:Cc:Subject:Date; b=Er2l+6NauL9234lJe7ylyNTS7h2FxAYZxIGdbUrnqT7VfXoom0z5tvfFX+wo/kwNT XogrjtbgxYUWy1xFHaL9wpsWjPnsRHYyd171U+cbZ7NhD0Zrkmbq0fvI/Nlm3Dm2YI 697gvVaod9WwwGS9U5lEBC1TMbmpsMo3zofyGKqDDjjViKFNG7tiIJy0cu1vux2BOM OFZykYnrx5D4/UXRyAglnMe8cJohqJRv5ZwAp2qcSLqjDTVPhDgsBCUyGK2281IPvB 5zntwOGXgeO3sKoRnUYOWvFQWIKzfmgpaWC8HEJbAIYnKBVOb/McdJpLFV/1i+MLWR rBQD1EiMkBQKw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 30 Oct 2023 15:49:31 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-nvme@lists.infradead.org Subject: [PATCH v2] nvme-tcp: Fix a memory leak Date: Mon, 30 Oct 2023 15:49:28 +0100 Message-Id: <7f132cc47e627d63ddb084f3d0fcad10956d1e35.1698677322.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 30 Oct 2023 07:50:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781192357409823015 X-GMAIL-MSGID: 1781192357409823015 All error handling path end to the error handling path, except this one. Go to the error handling branch as well here, otherwise 'icreq' and 'icresp' will leak. Fixes: 2837966ab2a8 ("nvme-tcp: control message handling for recvmsg()") Signed-off-by: Christophe JAILLET Reviewed-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Reviewed-by: Sagi Grimberg --- v2: - move ret = -xx; to the main path [Christoph Hellwig] - Add R-b tag v1: https://lore.kernel.org/all/f9420cde9afdc5af40bf8a8d5aa9184a9b5da729.1698614556.git.christophe.jaillet@wanadoo.fr/ Personally I prefer v1. Pick the one you prefer :) --- drivers/nvme/host/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 4714a902f4ca..f97711fc9f9f 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1423,13 +1423,14 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) nvme_tcp_queue_id(queue), ret); goto free_icresp; } + ret = -ENOTCONN; if (queue->ctrl->ctrl.opts->tls) { ctype = tls_get_record_type(queue->sock->sk, (struct cmsghdr *)cbuf); if (ctype != TLS_RECORD_TYPE_DATA) { pr_err("queue %d: unhandled TLS record %d\n", nvme_tcp_queue_id(queue), ctype); - return -ENOTCONN; + goto free_icresp; } } ret = -EINVAL;