Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2185542iof; Tue, 7 Jun 2022 22:31:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww9dDGRNWT9ueVF8MtxBEIle1weIoKOj05qwXS+GlE3iwCbe4HQwHiwtymQoFbXsAC+M68 X-Received: by 2002:a63:d013:0:b0:3fc:e50f:8e2a with SMTP id z19-20020a63d013000000b003fce50f8e2amr26644832pgf.283.1654666315578; Tue, 07 Jun 2022 22:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666315; cv=none; d=google.com; s=arc-20160816; b=BqaFRJoULyg7dSIuWh7f4ZaayP0klw07f3F1Xx+6RFdWI6GVrWjQzuRWlFNf1hfe7e S2qiEh+FEK/hSl0FyxI6EqJTyzHXN2KFKtHzYAJ/R5IHqI8pTAlRb00AOJLJBKhga20I 49O8W+4HWrVjfZu/svOFr1DgIaNNPqq9EzK1nko4bZHlUV2xPrcNOn2HNBxHdJt/OEze j4UliqJ29Ul6AUpCxN4p76Vd+dY3wmrtDxMXix6OGp5A48H+C+TGrLPyrf9+fXIKVh8G HM19AExyYKfeJFS55wFjBSRlufssiKhATDRpn7t2GIQTYuJrR2hCNQIzlC9Tlk8kl1j5 +rXQ== 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=u+hJvvVCJtIe8IN2WRhrql7wAQd3jAUsIqDImjkKdK4=; b=bnC2W94FaK7M8irBRixegg1+tiJujv+dqpr2wz7puEgB6aA3PcWxqGaER4GJhqglM2 c4RVURdLpxUJPR3f3Fs2PJOZcoeuZJjrkbSLTEvHEcujew9y3xJrKV8Vrzh/vRA2HY+a dALvfSihdAztKDIXmfJUcTmsdUa2fEGk5kD5ALhCy+7R4YHvNJg6TdJSfpCZJscCc1wx SlcxFGtKYDxOolZ0EJK3atjiLNUIHJoSjNrhliNDbkv3ET9Qde/5ummfd1oFc7UN6qcx 1bREYwgpAHEmZY9kXNTqVMOalRIGruZGipa3ylKo34/lItjtwmSPd/RsTXRWOcbBEBlI 1bRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E05YtYol; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g129-20020a636b87000000b003fe1eedd6b8si3056585pgc.452.2022.06.07.22.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E05YtYol; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AE663163F5B; Tue, 7 Jun 2022 21:58:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382311AbiFGWDw (ORCPT + 99 others); Tue, 7 Jun 2022 18:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378736AbiFGVDg (ORCPT ); Tue, 7 Jun 2022 17:03:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0159E1451E5; Tue, 7 Jun 2022 11:48:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 45E8C612F2; Tue, 7 Jun 2022 18:48:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 525C1C385A2; Tue, 7 Jun 2022 18:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627718; bh=YONjxaeXJNfdjI6X1ZBJqFnOHU4P3dRFG2L57MY6MtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E05YtYol4r6U58w/TarxCg7ynnAHFDppkzKiUqgpmjyIDbh4zMxalKpoBEeFtusFq eYrZR1pP1cPqujD8LmVqUymPM7ByPSNAHOQCMtH/6VOTecdg0aZLJ9Zo31I7DDJzYw jE6M3OZ74s8xX8a1wJ21aO1+QG60S3nVGpu1MJdQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Konstantin Komarov Subject: [PATCH 5.18 027/879] fs/ntfs3: Fix some memory leaks in an error handling path of log_replay() Date: Tue, 7 Jun 2022 18:52:25 +0200 Message-Id: <20220607165003.463322950@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET commit e589f9b7078e1c0191613cd736f598e81d2390de upstream. All error handling paths lead to 'out' where many resources are freed. Do it as well here instead of a direct return, otherwise 'log', 'ra' and 'log->one_page_buf' (at least) will leak. Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") Signed-off-by: Christophe JAILLET Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/fslog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -4085,8 +4085,10 @@ process_log: if (client == LFS_NO_CLIENT_LE) { /* Insert "NTFS" client LogFile. */ client = ra->client_idx[0]; - if (client == LFS_NO_CLIENT_LE) - return -EINVAL; + if (client == LFS_NO_CLIENT_LE) { + err = -EINVAL; + goto out; + } t16 = le16_to_cpu(client); cr = ca + t16;