Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp576580pxx; Wed, 28 Oct 2020 11:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCl+H7vVhlGpg3HMPt3CU6MS4WvGEyjKhn9EQG5SvGAI/qLecQShMq1HmPI6IVU53SeotE X-Received: by 2002:a17:906:318f:: with SMTP id 15mr414344ejy.180.1603909839216; Wed, 28 Oct 2020 11:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603909839; cv=none; d=google.com; s=arc-20160816; b=MW4Iwzy0fgU/Nt8TAOMVzPWTxdNssShMz8l8n4hOBKh5YE+y2jnS7jUiOFYaqLuAVc /D3ANYFSWchbWwwDEbMUuDqCtEl3GIN3bk7KVpq8nKfrhsrdKrhKTjd0qN2TtJh6XaX6 c6oduaxX6CnFGWICBDoq+biHs1Gk9QBMUFVsILBQvB/k70n/TOP78ICojQvD+cSkcfkf 7/LciKEziSEAlS2MwhYbTXau7BW0c5ay3HIY/2C7GxwxFhrln0wgqM0fhsz9a/krJ7kY 8l85yzVyMhCrzbzReXJWOYHe16pNzxEqRpAupaRVNBacZRqgYNFtqerOO3ASu+MYVQzO vbFA== 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=QKK146KpqILG90QCIufDkbeAIwyyOmRwFxyct9BxcYo=; b=Tqh0G/c8+HwjMWGe4Q7mOSsFq0Lw4YnQJUUxP4kNZHdGCBycQCUMRTwIGwlWMkouZh Vjw/jOacCawQv/kvZSFJ42Q9UGbkXIjFoHucpx3epTSOq7YehOAnU2BhSSpgPT2IKOTh rKz4SDv6jmjAhWpK97awjsMI1SPHmArJA4RWsVkAIP07C5sPDju6d65vrQ8+CC4p2ESW BRuUZhUJNcgq9rnMKI60IpdGxV8d8iI5yzrC+U5mIhqHRf8J6BIAq5bqqK+bkXR/zs0+ dhyBXecgR2AVUEoF6zcei0SaNGCTsWKRfzFJdz9S+gIKpWdm3wM8fCMowEAK4lEOA5Kx 6/Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I6U9Rnpx; 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 n18si9672edr.422.2020.10.28.11.30.17; Wed, 28 Oct 2020 11:30:39 -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=I6U9Rnpx; 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 S1825094AbgJ0SIi (ORCPT + 99 others); Tue, 27 Oct 2020 14:08:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:38058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757057AbgJ0OQD (ORCPT ); Tue, 27 Oct 2020 10:16:03 -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 4CB4B206F7; Tue, 27 Oct 2020 14:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808162; bh=Aa89ekcP0bkHteM/86ph1fGH+lQDJMLPv5zVTXiphj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I6U9RnpxgqtqW1IB9mYHqP29r5QWTjnjste7bSfcmwq24tYJtgA+hsqXcqpiLLUs5 k6oMDF9FI/8PX46/yB8jTqjpHjr/3LQXiihEk59iMS8XL/o9v8cP75hpNCqLFpxkba FVzGrZDqVOXoS2GeiEgDiPUM+etrTIniwqF+Gpog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+c9e294bbe0333a6b7640@syzkaller.appspotmail.com, Jan Kara , Sasha Levin Subject: [PATCH 4.14 180/191] reiserfs: Fix memory leak in reiserfs_parse_options() Date: Tue, 27 Oct 2020 14:50:35 +0100 Message-Id: <20201027134918.390809754@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@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: Jan Kara [ Upstream commit e9d4709fcc26353df12070566970f080e651f0c9 ] When a usrjquota or grpjquota mount option is used multiple times, we will leak memory allocated for the file name. Make sure the last setting is used and all the previous ones are properly freed. Reported-by: syzbot+c9e294bbe0333a6b7640@syzkaller.appspotmail.com Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/reiserfs/super.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 9caf3948417c0..fbae5f4eea09c 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1264,6 +1264,10 @@ static int reiserfs_parse_options(struct super_block *s, "turned on."); return 0; } + if (qf_names[qtype] != + REISERFS_SB(s)->s_qf_names[qtype]) + kfree(qf_names[qtype]); + qf_names[qtype] = NULL; if (*arg) { /* Some filename specified? */ if (REISERFS_SB(s)->s_qf_names[qtype] && strcmp(REISERFS_SB(s)->s_qf_names[qtype], @@ -1293,10 +1297,6 @@ static int reiserfs_parse_options(struct super_block *s, else *mount_options |= 1 << REISERFS_GRPQUOTA; } else { - if (qf_names[qtype] != - REISERFS_SB(s)->s_qf_names[qtype]) - kfree(qf_names[qtype]); - qf_names[qtype] = NULL; if (qtype == USRQUOTA) *mount_options &= ~(1 << REISERFS_USRQUOTA); else -- 2.25.1