Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp301228pxx; Wed, 28 Oct 2020 05:23:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2kIGBaDtZGdu0wpqG4y5qUq5vxM4Ut8yArgYUAsMF9pwu4BHczKhKDGr9MBF8icNUf4E1 X-Received: by 2002:a05:6402:754:: with SMTP id p20mr7409642edy.109.1603887806777; Wed, 28 Oct 2020 05:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887806; cv=none; d=google.com; s=arc-20160816; b=YhnalB5pSBYGARGAVUKgNCjzFZvhHibMNT0Wrz9Wd6wVN6C+zFO1xdB5Ui8Fad5G2R 0AamgX0PPIEIuqOKKhu3RMtv08AytNTEN5zlUoRGUqvc9wNFhT6oE+9iOgy66Rbr3YDj sX0DYX46ZCthELFuGDnhENU4TKWKwLP3pj1Lcm0lGSVk4l5TxU5sdTjF8WzNCOqZT+S2 fu49P4ujJR1zMnetYCE/XmifXPK0nNCcsAKNwgoPd/6rHSBBdLB2g+bgGc9b+sx/HVns 2uoasWyb8vwSfJokjiduFuPgHnt4Ag10RD4RoRd25m3BUQjExV92UErGVOzp7psPR5UP YpOg== 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=B/IMxe+qefhNFcJaAprQhbZoBD/H9zZNdb/RVUlTuHU=; b=RYkjAgPAPzvK4jtsSr8iXiBpGXCfjLSI0hcy7Lq9FQtpZmErY/wBT8gu8ljJ+RND5F UiLyDrB9478pKUxjJpG04Dwoj8foPXdb/7u0RDc5Z3zQPdP9uaKGOdP1DGDSExpt2a2z xfGIOgwo5Gabrfd4Cqh8xB00wcIiIWUvUe90dQ5UKS3UKuft1AwsTAIAr+6agu4hW1ui u3a/flcKk5LrQrxqzaypYR6Opn7O43Cf1LSo17OxhaVkXiho3QJTq14RH1gw7OsR2rJv HLvUC3kzHwzuf4ZsBf9vFEmQt8Xn5zzKtRi0P+6Mh5IkszRUzcP6uNNBDLpAIl2wjLvl lY0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2Ayi4w9q; 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 bs17si3022913ejb.543.2020.10.28.05.23.04; Wed, 28 Oct 2020 05:23:26 -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=2Ayi4w9q; 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 S1796808AbgJ0PTw (ORCPT + 99 others); Tue, 27 Oct 2020 11:19:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:52762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1796198AbgJ0PQI (ORCPT ); Tue, 27 Oct 2020 11:16:08 -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 E060520657; Tue, 27 Oct 2020 15:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811767; bh=TfWJq0F+eNJwR3zuDSJhyRJNiFATVZ7YZaKoLVaSsv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Ayi4w9qYZsRda/8FCF8NJzRamHXvuO8JS6CVKHjYwrtRN6mQWboTmZ6JfscUPHYh yzgAVEefJHwzVDKq76gFymFWWGndPpLg+YAdv3tOOlGYuM3sVryqcHnuPS/LRSLVJ4 zpA3UEVV5YdMcF51RiRDJ9w7gWzc8LPeim2bKJ1s= 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 5.8 609/633] reiserfs: Fix memory leak in reiserfs_parse_options() Date: Tue, 27 Oct 2020 14:55:52 +0100 Message-Id: <20201027135551.389626216@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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 a6bce5b1fb1dc..1b9c7a387dc71 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1258,6 +1258,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], @@ -1287,10 +1291,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