Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1633230ybv; Fri, 21 Feb 2020 00:40:34 -0800 (PST) X-Google-Smtp-Source: APXvYqxE3lz9AiQMd6F+werqIl9aqm1tpsU0uJN2PIdAIXgvQRlkWTiJe6k9srJMvzeRWCEg5D/e X-Received: by 2002:a9d:6c01:: with SMTP id f1mr26319048otq.133.1582274434055; Fri, 21 Feb 2020 00:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582274434; cv=none; d=google.com; s=arc-20160816; b=x+BYIsDO5y9VINntYSZpkXmAaTQYpp54MpspH9gz5toivfkESghOfVEz1wS+7BK04X 1m/O1+7cJwqxL5/EqoHkCtoQY6yuGrDz6edzPavSpS4rqBFy1yxdjwzpLE/uFGdRu0Jo 8YpdQnA+D3Uh7SZkichqlnlEY+UC9wIY3EGcZ7umDc9bqh2OuGXfn7IC136Rz0JLfJxK +JXdQIZ40OYHYD4fLKpCMhStlI9nmycpqfVfV1x4qo5CUclxOXvcO5rR1WhJAvtBsIcH whmV9CQ9abqnjk48vnI+jHzKSUw4TCxDM5Iyknb4Ox+jaNku0caO62Z4O7M30c7EzbVl 2gRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gw4Sq1UT7kv4XgGNAgx7zm5PdHc329bNs+nN/hPk9RI=; b=0XEBt51/cVPwi6ImmgnHO8090mkF/Mq1sfLjRQBenYJAylAK6x0tyEa9Kep27JrUJO JXwsdxHGhQ0huF9I1fNlqcnLhzJ0YPRq6gopic8xqF0C9yYxIbLikHkC7XhZ6HVWV0Cv lLOX20O9lq94TjKMNtjI8dus3zOgz8Imv1Ua5dgHUjnx58zW3b5KKpPwsRKvRAEqMvkK IeQinI0zx14mvS0G1cuzRKmIWQVp3HjTQLchzKpJe0L2iRtN6aGkKg93ulFzl2cTrsGu +WknK8gQU/O/b8X9S5pJi+5DfNLb39GhH/OcPIgEypFSxHi2YJlEp6CjB8xWzh7thh47 NCdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x9iksqhN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si1027798otp.57.2020.02.21.00.40.21; Fri, 21 Feb 2020 00:40:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x9iksqhN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731072AbgBUIAc (ORCPT + 99 others); Fri, 21 Feb 2020 03:00:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:60928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731068AbgBUIAa (ORCPT ); Fri, 21 Feb 2020 03:00:30 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 92031206ED; Fri, 21 Feb 2020 08:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582272030; bh=fWkVieqX4+okU8uVSg0m7NTofCEOdf4K60FWuuLXt9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x9iksqhNfoGA8XiYKQWXYwQIIzhnYXFDRgu/pGrd8ouLdUhbn9rXj2z2qfQh10Tz6 siwM0yT8C1go77NP8K+kags2aN8SXgeBYC4ZL0wUwOx1GYi7/kvYeWSkvxEyD5QTuF 0Esg9HJTrukBoDFgMOBNhbzZop0NqoeNZOzG9bfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Anna Schumaker , Sasha Levin Subject: [PATCH 5.5 388/399] NFS: Fix memory leaks Date: Fri, 21 Feb 2020 08:41:53 +0100 Message-Id: <20200221072437.736264325@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang [ Upstream commit 123c23c6a7b7ecd2a3d6060bea1d94019f71fd66 ] In _nfs42_proc_copy(), 'res->commit_res.verf' is allocated through kzalloc() if 'args->sync' is true. In the following code, if 'res->synchronous' is false, handle_async_copy() will be invoked. If an error occurs during the invocation, the following code will not be executed and the error will be returned . However, the allocated 'res->commit_res.verf' is not deallocated, leading to a memory leak. This is also true if the invocation of process_copy_commit() returns an error. To fix the above leaks, redirect the execution to the 'out' label if an error is encountered. Signed-off-by: Wenwen Wang Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/nfs42proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 9637aad36bdca..e2ae54b35dfe1 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -343,14 +343,14 @@ static ssize_t _nfs42_proc_copy(struct file *src, status = handle_async_copy(res, dst_server, src_server, src, dst, &args->src_stateid, restart); if (status) - return status; + goto out; } if ((!res->synchronous || !args->sync) && res->write_res.verifier.committed != NFS_FILE_SYNC) { status = process_copy_commit(dst, pos_dst, res); if (status) - return status; + goto out; } truncate_pagecache_range(dst_inode, pos_dst, -- 2.20.1