Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1985187pxx; Sat, 31 Oct 2020 04:52:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPOn/XAng3d2UNRFti89EtM5mOLy/vS1Db2ZLNTrgYHSbAl59DFPhJnXxIng4J8+7I53TY X-Received: by 2002:a50:e686:: with SMTP id z6mr7180778edm.188.1604145161030; Sat, 31 Oct 2020 04:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145161; cv=none; d=google.com; s=arc-20160816; b=WeJz6E5CHDRPfQ6iOerTwK9/WoBqD/hEMUmLYppCkimZYUisUU05GSXRuj9edlm2lv zbotUCultwYx16ZQcZzgeHkcS/HQiCKyDCUPDoQ4YEbsMtqRTV8upB2ecMyx/RxzLSuj m7vwrvRoc0jfJ+okFV7r84mbjTBK1jl3dV31Bv2NzMwVM2qkgle7DxBt+yTbbboi88+y Yv3abuRLA/ygn0qwSm+DyWQZRQecdAkt0tciqw6iG0RfbL7G5pRyNyhVMQg0nKjC7O8t Qeaic8UVSfPAvJWmpU8wlZvKPcHIxoeU5VHt99E0uzLXS7TfJCZ8/rgXZhdIW6U+lS0D Y8tQ== 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=NeGdlmCFLd7gwfZHrP5XpT2oBC+/BFW+qrhdPCcxSmA=; b=ghD2HaHoeAN8epM/7I35BxbVXyHf5GxGP+o0ol4VLh+/M5xU4SDjJai7Y3rtkFtmns jzel8qlo5uG1JFQumeS13kwUEfykYEGv43NqFqtBxACao/NhifBAROlDyUFf6jOMTyjM gHkZfo+A22iSs4OKLhWByXTduTyzhAUqn0AfzfVvRrTX0BSaPnz3HVlIF6LOJKLRO50A U9gpd9SP+U8ngQNmG9x/1hYnQM/NZQXl8JwwlF+lWNs64w6lvIshjIOo5Rv1xD+k/fMS XtjMvt3XD+QFsC1Z76Bs+mkJaJDxTNYQ5UG0g6AzFC5j/U+7EXKxDnM8zAPxRK5O0uF4 wI0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QNan2N1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si9031332edc.350.2020.10.31.04.52.19; Sat, 31 Oct 2020 04:52:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QNan2N1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727589AbgJaLlV (ORCPT + 99 others); Sat, 31 Oct 2020 07:41:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:40328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbgJaLlQ (ORCPT ); Sat, 31 Oct 2020 07:41:16 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9ECC120719; Sat, 31 Oct 2020 11:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144476; bh=Ze60y2mI3LTiXlkco5PSOa3oUKSgq0I/299naj4iKYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNan2N1s4AeDqYiksam4qyFOv2jkVgi2TFuMyu4kEfW3bQTponBgsnFDq7rPgP04t XUVOXbOL3V21jXhTTbrZOKkv7IGuVUKy+Qz5wLNlk15YH4SlYIKj4SjfJJvxx1lkjP j55XZtsYiEEp9fx+3P8E5f3GfCos809K6t6mf/0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vinay Kumar Yadav , Jakub Kicinski Subject: [PATCH 5.8 33/70] chelsio/chtls: fix memory leaks in CPL handlers Date: Sat, 31 Oct 2020 12:36:05 +0100 Message-Id: <20201031113501.084979443@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinay Kumar Yadav [ Upstream commit 6daa1da4e262b0cd52ef0acc1989ff22b5540264 ] CPL handler functions chtls_pass_open_rpl() and chtls_close_listsrv_rpl() should return CPL_RET_BUF_DONE so that caller function will do skb free to avoid leak. Fixes: cc35c88ae4db ("crypto : chtls - CPL handler definition") Signed-off-by: Vinay Kumar Yadav Link: https://lore.kernel.org/r/20201025194228.31271-1-vinay.yadav@chelsio.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/chelsio/chtls/chtls_cm.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) --- a/drivers/crypto/chelsio/chtls/chtls_cm.c +++ b/drivers/crypto/chelsio/chtls/chtls_cm.c @@ -772,14 +772,13 @@ static int chtls_pass_open_rpl(struct ch if (rpl->status != CPL_ERR_NONE) { pr_info("Unexpected PASS_OPEN_RPL status %u for STID %u\n", rpl->status, stid); - return CPL_RET_BUF_DONE; + } else { + cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family); + sock_put(listen_ctx->lsk); + kfree(listen_ctx); + module_put(THIS_MODULE); } - cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family); - sock_put(listen_ctx->lsk); - kfree(listen_ctx); - module_put(THIS_MODULE); - - return 0; + return CPL_RET_BUF_DONE; } static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb) @@ -796,15 +795,13 @@ static int chtls_close_listsrv_rpl(struc if (rpl->status != CPL_ERR_NONE) { pr_info("Unexpected CLOSE_LISTSRV_RPL status %u for STID %u\n", rpl->status, stid); - return CPL_RET_BUF_DONE; + } else { + cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family); + sock_put(listen_ctx->lsk); + kfree(listen_ctx); + module_put(THIS_MODULE); } - - cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family); - sock_put(listen_ctx->lsk); - kfree(listen_ctx); - module_put(THIS_MODULE); - - return 0; + return CPL_RET_BUF_DONE; } static void chtls_purge_wr_queue(struct sock *sk)