Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp902744pxb; Wed, 29 Sep 2021 12:07:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJC3ChD7aaWLxswM5W4F7sKRUTqmjL0uBIFhfys8nwIUkRBNBPCHH8Aug8dw4GXnE5VG4Y X-Received: by 2002:a50:e145:: with SMTP id i5mr1938098edl.16.1632942419801; Wed, 29 Sep 2021 12:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632942419; cv=none; d=google.com; s=arc-20160816; b=u4c9bLTtrlqNPWDLt93Jl2IQKaJrJHIX+Ha0Ng7Y8IGEwhVGnTeRuHIW/somEABe4r UzhpqWIlArXL5u9JSzp8VaZ0okCKcq3HSUODtYr1JazPPjajRCS6yZtE/c63i0eUyoxZ DNhJQm/RimIZNHBkLhsvP/efKZxNTI16nshcT/gf6csCueclJrMaFji9Li56odeBHQFU S0tYmeP/Ehim/lGAOB672thu3O6Z4UW3IMysTBCINcJIldr9z5eQlOovepG3IYTh2od9 7V55sAhAWDjlFgEL6aSRWnOuTfwVGOOxQUucA2R3IyPKxOyuqEIbiJJEod7mtb73H0uJ ZGtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=G7Wdg9mT0Ns3YgyIT6a7j3pJ2ql5Pkil3NxCMgX2PUY=; b=QUJ28xp/4CvHEQsu1TmjZygmfsqFoMz/SUQiSw7Y1YDEN/DekyL89eGey7GvLlxEMW mouiIwHlkMuK8BYNToH2Vfyulb6jsL/miHzVqFUiAZBKWAG3DzrUeWmY2H54OUpuF0OJ 4AVHn0NV9ND1INX0gM0wjzzi75sUoukBuBvliBFPVBaD2GrwizXTtJ/fDU9oUAthel5L KzvfP1cZlb7qSpSVvfMeAkfiN4q1E/U0xzNnQBb9muvaODQ5w7s3vTrfvxGhjVGJeWIx V4UXQPGW4JAeDUpqG7s5Q32nMCAwFYmbVOh0tzAWn/IMEwDE29SLh76FXwPDblvYVArZ Gjdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=bZDHKNLK; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x44si858567ede.453.2021.09.29.12.06.18; Wed, 29 Sep 2021 12:06:59 -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=@paragon-software.com header.s=mail header.b=bZDHKNLK; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344551AbhI2Q46 (ORCPT + 99 others); Wed, 29 Sep 2021 12:56:58 -0400 Received: from relaydlg-01.paragon-software.com ([81.5.88.159]:57487 "EHLO relaydlg-01.paragon-software.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245276AbhI2Q45 (ORCPT ); Wed, 29 Sep 2021 12:56:57 -0400 Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relaydlg-01.paragon-software.com (Postfix) with ESMTPS id 34BE58230F; Wed, 29 Sep 2021 19:55:15 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1632934515; bh=G7Wdg9mT0Ns3YgyIT6a7j3pJ2ql5Pkil3NxCMgX2PUY=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=bZDHKNLK0RwZuWiV2SSec8AvXv/aZUBdQwHdsTIUbxV55nqeJ73Bbzehl+5s+nVGa Rrzt/FOjBcJm7KX4hTd+jCzQ1wwndTaY5PWU88V8hn7k5UdgzPMYVuQ3EYaBAbjivy 3opOWrCO7rEto/BLTMuBnq3XHgTPpnJTKyHvccV0= Received: from [192.168.211.131] (192.168.211.131) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 29 Sep 2021 19:55:14 +0300 Message-ID: <9b37cc1a-2951-77fa-9932-6052555ceca9@paragon-software.com> Date: Wed, 29 Sep 2021 19:55:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Subject: Re: [PATCH v2 1/3] fs/ntfs3: Fix memory leak if fill_super failed Content-Language: en-US To: Kari Argillander CC: , , References: <5ee2a090-1709-5ca0-1e78-8db1f3ded973@paragon-software.com> <20210928174423.z7a6chrjmmyezlsp@kari-VirtualBox> From: Konstantin Komarov In-Reply-To: <20210928174423.z7a6chrjmmyezlsp@kari-VirtualBox> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.211.131] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28.09.2021 20:44, Kari Argillander wrote: > On Tue, Sep 28, 2021 at 08:17:29PM +0300, Konstantin Komarov wrote: >> Restore fc->s_fs_info to free memory allocated in ntfs_init_fs_context. >> >> Signed-off-by: Konstantin Komarov >> --- >> fs/ntfs3/super.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c >> index 800897777eb0..aff90f70e7bf 100644 >> --- a/fs/ntfs3/super.c >> +++ b/fs/ntfs3/super.c >> @@ -1242,6 +1242,10 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) >> return 0; >> out: >> iput(inode); >> + >> + /* Restore fc->s_fs_info to free memory allocated in ntfs_init_fs_context. */ >> + fc->s_fs_info = sbi; >> + > > Nack. fc->s_fs_info is already pointing to sbi. We null this just before > we exit so it is impossible to be anything else in failure case. > We have seen memory leak once, but looking at the code of function I can't point where it was caused. Will try to reproduce again. For now will commit only "Reject mount if boot's cluster size < media sector size" and "Refactoring of ntfs_init_from_boot". > fc->fs_private = NULL; > fc->s_fs_info = NULL; > > return 0; > out: > iput(inode); > >> return err; >> } >> >> -- >> 2.33.0 >> >>