Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp176727pxx; Wed, 28 Oct 2020 01:42:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVg4jrDmCWGlKrjkvJgSHRqzA2C9zdOZO8V9TJFuU5fwEs0VzWMQNB7JSEiqG4OI8MLg5q X-Received: by 2002:a17:906:4c4e:: with SMTP id d14mr3555414ejw.186.1603874533540; Wed, 28 Oct 2020 01:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603874533; cv=none; d=google.com; s=arc-20160816; b=B3eZnylzTv3Qx34NXxPE6l4GfqyZkopgKgoFfBj++eqbL8bFzQNroF5xeci6zee75C RBFijAVBcWGhQwXoLrCI7dCB1trJCLeHCefQTG0F5yqYRMquAfN+UzYKPftIn/hbV2Gx PNgSuzkdu9IFIwWo8TIG/ECIzCe99EM4Xms1n6S/FnB8vOzl2+enD1qjQlbbuTm9DxBr IDHeu6NLGxCa1HyfSsK9iV2NoMkODb9xWs6K3+sCHnjwhWOhrIQOLl3+LTLkhuwXbCrm aPXWgIkx3sN7PxBRdRmSPISFDpFHyy6PoA6nV2r0GRrTfSA698j7LJ3Z+k90AbormApJ QS7Q== 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=rsLkQtttz2/nuWDGgxR/r7Ut5a+HcQvhbBJW/MbY1WM=; b=XoZp2/a/ypePiKEysccDqKgUncVCy1o1ezrQCh50LsxZugXllpZnXJDUuZlj3ZNduV 8hqNc6aogA2ElM/5Xx4pyCsHJlPBNK4prP5t4oi5p5GBRGpPaXDUUsGYaNMTqfbvC8vs 9/5XFymVNkkN5QlLbguLDEMv+aQpj55GhluyKKvvSQnQobKMuxrGc3xBQRcl9pDwZATX PTfvGaAvQzsWHzOAUhGqm4KXGkbENDXnl7iJ++13wFzG8UE56OgzHLYK1DykBgk8dmxY 7nvgCAWwJ4D3Rm1JFo1GJifi8p8zynUEswjSWXBmhTeCXlm2PWhT1WElxt0zhZODvxVM 0bmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PYcl1By8; 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 a42si3838927edf.535.2020.10.28.01.41.51; Wed, 28 Oct 2020 01:42:13 -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=PYcl1By8; 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 S1755027AbgJ0OIF (ORCPT + 99 others); Tue, 27 Oct 2020 10:08:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754970AbgJ0OHw (ORCPT ); Tue, 27 Oct 2020 10:07:52 -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 3C8EC2072D; Tue, 27 Oct 2020 14:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807671; bh=qQkpsY95igRkNtXkV+01ckVVt9mzZ3IvlB7j+mGHTu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PYcl1By8rP/obQDX7gO+HGZExctEVb3y4WUi4CyV3diRh8HgHdSbRHNRMms3CBz5c lxN7sFURxyfWcXgkqZ7+UycQq7IXdGNtdzPYuajKVeKd57hAIrB58kbJs8K/+iiMkH 3oUOA3+U9CWwYHFP8aCJbbhVQ+3qTNvzrY3haOy4= 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.9 131/139] reiserfs: Fix memory leak in reiserfs_parse_options() Date: Tue, 27 Oct 2020 14:50:25 +0100 Message-Id: <20201027134908.373144979@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@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 677608a89b08d..c533d8715a6ca 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1234,6 +1234,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], @@ -1263,10 +1267,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