Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp166984pxx; Wed, 28 Oct 2020 01:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxevGCpy9lSrgsSP7JkgNyAmQGD9+O0/WoYGfYhkdD2Fx5Al1fDPG3zapTyq8AJpMuhI8h/ X-Received: by 2002:a17:906:a282:: with SMTP id i2mr6318815ejz.39.1603873311336; Wed, 28 Oct 2020 01:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873311; cv=none; d=google.com; s=arc-20160816; b=NpvDvpSjBuHFj5hYiFH8CcA3BDrChwtvfm5OhvmAh7t2L7QoqgMg1XxgvVR9HbcPOD l6YeBGjB01XPGrL1B5lyKJnvuIxcwTTS2NiSF49GpSSpAyGXCw99egfbWsc1m8ED8zik IL+5oyP0KjEmXOkeNipcpiGN+xBem7QxJXzrHnaao5DPCtsZlEdl0WsTJtSNKA7huyP6 cwHDuAtqwNiJqpHemFa5S5ExUCGuqp6RdcSBF1QJO7asjinzQfOqd+uZYLJUDSQ0fTe3 N3f1M1hEOqu7f208iVFWmb174zx7NjNhNzNbgXzhJhj22mZdOit5Slo1hTUuUlzYRYMK urQw== 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=0VPe3cOWBC+HfDsFdxCfZ9/QwIhSDEz/oIjGHXJMMqw=; b=KsxHWR9utcLF1mVGnk7Dfor7H69rqa9U5NXOa8fzlI1c5TNhogCgvCfVjt1Xn3+3x+ xAURJ9Sk1FPiRAT3B3uW64BZkaOqW//KXIZgMcKKaRN6YQcuzj9JYHPFxvj4/LZJkF4P rVujFZDyNHf32SfyVfgeXy2J+GaxrVXWy1OatP9r0fwMIAKfqbO+39W9VLNWriviX83M 5gliCCb1+l1Kr542K8ql7vurRFD4sZZG1twDcP6Mr4xURQK+/wcG08Hyb8ktENcoeG9o cGHidVrYqazug80XBpx1/syjDn/T3E7hbuPkbPMM3veA48FodTexgUtVExdqmpD32ez5 iLMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BBh+7FIn; 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 bt10si1135660edb.503.2020.10.28.01.21.29; Wed, 28 Oct 2020 01:21:51 -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=BBh+7FIn; 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 S1753753AbgJ0OB7 (ORCPT + 99 others); Tue, 27 Oct 2020 10:01:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:48846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753629AbgJ0OBM (ORCPT ); Tue, 27 Oct 2020 10:01:12 -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 989B4221F8; Tue, 27 Oct 2020 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807272; bh=4urMCYdTXLt4wCaEBuuT4e20rgwEIUjK9HnD1rTAkGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBh+7FIn3LMtndYN+aij12n7zSRonb9HUCup14r7uGzLeLGkqecGnCHpy9qvWqDB3 Rieo/BFJFByyOVXJl0fumZB9qFDdHfAuUFXgPxHIk/cJkS8fcLJEjkPc18sRS/xpwi 3QHF2+auwla6fFDVt8dIEmoo5Hzkf2EQnqfE9I8w= 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.4 106/112] reiserfs: Fix memory leak in reiserfs_parse_options() Date: Tue, 27 Oct 2020 14:50:16 +0100 Message-Id: <20201027134905.559879356@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 f9796fd515315..503d8c06e0d93 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1232,6 +1232,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], @@ -1261,10 +1265,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