Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1121013pxx; Tue, 27 Oct 2020 08:43:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPaxOxBTDxnqmue1I259sv8OBqCEBPNXdNOxprKjIPnPBFxset3ZP2saitrJuglMkS9k5s X-Received: by 2002:a17:906:68cd:: with SMTP id y13mr2831351ejr.230.1603813429501; Tue, 27 Oct 2020 08:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813429; cv=none; d=google.com; s=arc-20160816; b=ScEunoBTU62K8loShzsBRdpy+b3lMv+/j/omkOuln6H23m3cfaU9uNOuY9GKuhzRiV iesQr00Y9B+iqGYpPj1+HsCpBnf2FPvn0cF+xVlzaw05+hiNz23xf7jAO46KGd/c5rui v809EO0Blw5WpGEODWx/SlCXejN6xu/fzsgZRjBM4Y4d5q2ZsWJc+bHdpwWwD8GENAup UZcgWZ9jAvVH2Vha8NdyEYMTq1T4CuQ4w6B33n02lbcgdBqd0e/hBhfffprMMfoM3Jqf JX/b6liZGslRLQjwMBKCk/teG7EO0k7UrvOwiZIA7+vMWIfP3n4eUvZzuPJfCfVqOzKG x6lg== 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=eXeSEkeE/DSTLje0Wpvf4Gs1zPeP0441xPn7laXjJ4MG8GGoHTtOlAReul4t9mikhu OxbgepVsqfrVt3I4yyqSCYRD7b/tGD64Oqj9hFMb+tlVWb/HWIl9c7PtJhG8lpHTA7c2 huJ/lbZASOZ+lXeMD6xKiqoqffXUbmbrywUS2ogYLpjMzseS3o6+QghPAtAvMv9Cf5nw 8d5hRqiQ13MfPig9qWYOrQQX63nsCKNUt1b/ybn12N+Noo2BF8pNAPgDfDjek3si8dv0 jSTduZS+EilkGYUdK6H4JlBpH78xXDLSRa2u+DQKIx7nhP4/G24sFL3KzADtvPEOENiq YSUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ewdnT8We; 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 gh7si1209666ejb.57.2020.10.27.08.43.23; Tue, 27 Oct 2020 08:43:49 -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=ewdnT8We; 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 S1764174AbgJ0Oqc (ORCPT + 99 others); Tue, 27 Oct 2020 10:46:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:46306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764148AbgJ0OqZ (ORCPT ); Tue, 27 Oct 2020 10:46:25 -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 DE6C02222C; Tue, 27 Oct 2020 14:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809984; bh=TfWJq0F+eNJwR3zuDSJhyRJNiFATVZ7YZaKoLVaSsv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ewdnT8WeVRXq+fD/XQu5qY2njonhRIVTvZS2kkuK+AQR32Lu1/wQwz9qC417b5ReJ MF0V3BaGq5pW3orzotUgRP9RWmzvWkJrsY8brRUJ6C8fMQWNSDmvdd0cK6udEaOc0J F3DdyEu+ppRrLmCtXxKFXk/ktODNy5jiOmHzI1Bs= 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.4 389/408] reiserfs: Fix memory leak in reiserfs_parse_options() Date: Tue, 27 Oct 2020 14:55:27 +0100 Message-Id: <20201027135513.023148695@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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