Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp799627rwi; Wed, 19 Oct 2022 03:10:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4akM6utom7MnwUr1PMHQHZKxPZHTvskAVb4qb9fTAIT3aDjVBRt/3uUH24CRDPj7si3AsM X-Received: by 2002:a17:903:246:b0:179:b6d0:f8fd with SMTP id j6-20020a170903024600b00179b6d0f8fdmr7661498plh.124.1666174205322; Wed, 19 Oct 2022 03:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174205; cv=none; d=google.com; s=arc-20160816; b=zvMdCuXOmyEA2C4ABU7jdmdRhsdMyVQY1KriZmcvUOx4Sfh4PJivVrBi3DUcEueJlp uaFIg5s/Ud7qeL9JCnsZQAWlpqtqLC9uerUq7WB/GUqqhjtbmXXliAkjOL63uC0oa43m z/m/lT1B1IOGLbOmsiD9EWuJovn1Y27Ff2wonEoYJgne8eQv7bFO15kJdGITRSonAAJT M7sC3BOmVUrkxcwPYFKt2F+IiIeNZUwEchMnc8bpEHviWTY2dtUxgHvuSqJiZ1OwIpWs Zs698JfMAOL+R4X8xGO9VGRjRhgdKIm9g4ajF90tvAfagCy4eCboxUzmpAXQrUeEJQHZ orig== 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=cZofKYENmurOZTvSXKMo94k2spzaldeBtbxYDPdasCE=; b=aQ7V6lzXaeFdYY91nLLyCy5/YWXL7QmpRHXQbfc0vVfyImq/9yNc4KrOH0LqRTExAV eOKPeco9r5kvW8xa9nHqKWdveFJ4zo2f7KSXyLJBBH1QLtmZ/JtcqqWe0jvZuaNqkym8 fjYbh8GCm/7tQqXmZ9YtcSMoeGLrwCVZKZdtNwRz8eyQY9wjntZYlI1DnkbrtitCS8OB /Im2qYfJdUXysYANilq2CIyWT3AAmkB0kHMeqx0O9J+9lHjYm+gxX2J8RJdqTthep86l 4KTEQaZlqM+8JEhfdNDoY3A4rdDAAyfON1bRt2QuKdM92vuWQkx0P+pDA1Yx4DYTVWqS MFtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lXrtZHnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a635447000000b0041a4bf40469si18914299pgm.271.2022.10.19.03.09.51; Wed, 19 Oct 2022 03:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lXrtZHnK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232587AbiJSJHg (ORCPT + 99 others); Wed, 19 Oct 2022 05:07:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232786AbiJSJFH (ORCPT ); Wed, 19 Oct 2022 05:05:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B16C9DFAF; Wed, 19 Oct 2022 01:59:14 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D234861838; Wed, 19 Oct 2022 08:48:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAFA1C433D6; Wed, 19 Oct 2022 08:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169289; bh=cEznBf9bvTB/4ENmafZ5o4nl4xs2vm5vB0HoS9fBxMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXrtZHnKwr05CjGJekuTytWwLLBIATLhTBvtn/mrJsRVhDQJuxyV96j2ygn1f/eIf 12m7mil4796h4ZBCe3tjG+Ac3FWYmmwqZqiheMcNFVgbs7PUcM20gNUEVpBwyTIYQf IPfdTTJNYYI24rQMBeYASDMLtDdKiU93gCXxV2G8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 6.0 221/862] nfsd: Fix a memory leak in an error handling path Date: Wed, 19 Oct 2022 10:25:08 +0200 Message-Id: <20221019083259.801867037@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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: Christophe JAILLET [ Upstream commit fd1ef88049de09bc70d60b549992524cfc0e66ff ] If this memdup_user() call fails, the memory allocated in a previous call a few lines above should be freed. Otherwise it leaks. Fixes: 6ee95d1c8991 ("nfsd: add support for upcall version 2") Signed-off-by: Christophe JAILLET Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4recover.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index c634483d85d2..8f24485e0f04 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -815,8 +815,10 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg, princhash.data = memdup_user( &ci->cc_princhash.cp_data, princhashlen); - if (IS_ERR_OR_NULL(princhash.data)) + if (IS_ERR_OR_NULL(princhash.data)) { + kfree(name.data); return -EFAULT; + } princhash.len = princhashlen; } else princhash.len = 0; -- 2.35.1