Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1988506pxy; Thu, 29 Apr 2021 20:45:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa9h0rfrzMyrlFD9f0w3InTOgZmWveKqgOwtXoWYIB2ztbVjXf5LojdgkMNnKCee1tIbEi X-Received: by 2002:a17:90a:684b:: with SMTP id e11mr3396051pjm.87.1619754340470; Thu, 29 Apr 2021 20:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619754340; cv=none; d=google.com; s=arc-20160816; b=TuXfHR3unEHEmoWQCwx8bRMQamZYRikEgRbV4neKRk/j6R6k86iCImw10CSq7cNkIP shNoHimrDJx1eW1MlJmgamRtWVAPzkPbkqEYVu2BjF8r8e/7GO0CRrjC+gszacnQn54v gmG/JLo90lSYD0hKugGwcYsWwznEJXOhjIgMxownXB9bdijz+Eg387CsDAB9k0QgeRSX wseAaxLJ3zcuW5ve6cTWxEbvq3ucELKDkRpHObEvsnx4RzK27wF5Bv4K4mf5n67QZPqB ikdM5gH9y/DPz8TD8qSL8cgkxbIGWaBUW8aBJhIlJOC2KDpYNUk9gEXrEcK+peLxVcGd nMXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=o+GVEag76FKRROshUcxn1ESG8IavZj8JBsd33CWhlzE=; b=tUuz4r9P0RScQpMKqaIjBCJM+VufJ87Kqeo4HmB+o5hfDX6Y8P12lYMOTnpr1vDWMW C/3vBQXIXehBYi3HI46GTGtf0je0XkjptWsQ3qF983XMT3+VNp39YCxG99TRFQB5nGzY ZIp9HhIAGhXoK+sUrhiAHi6ws85aYdGNtXSmWL7AqYV26W5ILQnjz2ngc1rIplmoSSUv hhO8jGVVLjbgz/iL1HINoWA8L6Y1wJhgsAER22OMp6S8kmpSp7mlbPfoTz4phuxxpdFP QKwJQdfZmy1EFC7HnzOZD6kmqiRgSGHJgx690XRY5Et3J7C80NE1qzFMv/Egq3zPRcF4 w+8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f12si690370pfv.242.2021.04.29.20.44.57; Thu, 29 Apr 2021 20:45:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbhD3Dpn (ORCPT + 99 others); Thu, 29 Apr 2021 23:45:43 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:35789 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229591AbhD3Dpm (ORCPT ); Thu, 29 Apr 2021 23:45:42 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 13U3iX2U017640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Apr 2021 23:44:33 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 00C4215C39C4; Thu, 29 Apr 2021 23:44:32 -0400 (EDT) Date: Thu, 29 Apr 2021 23:44:32 -0400 From: "Theodore Ts'o" To: Pavel Skripkin Cc: Vegard Nossum , akpm@linux-foundation.org, peterz@infradead.org, axboe@kernel.dk, pmladek@suse.com, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+d9e482e303930fa4f6ff@syzkaller.appspotmail.com Subject: Re: [PATCH] ext4: fix memory leak in ext4_fill_super Message-ID: References: <20210428172828.12589-1-paskripkin@gmail.com> <3c3877a4-fef2-9e24-f99f-2ecc46deb7e4@oracle.com> <20210429143354.418248a7@gmail.com> <20210429230956.6ad23897@gmail.com> <20210430010547.38f27e39@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210430010547.38f27e39@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Apr 30, 2021 at 01:05:47AM +0300, Pavel Skripkin wrote: > > out of the thread function. That means hanging struct mmpd_data off > > the struct ext4_sb_info structure, and then adding a function like > > this to fs/ext4/mmp.c > > > > static void ext4_stop_mmpd(struct ext4_sb_info *sbi) That should "extern void ...", since it will be called from fs/ext4/super.c. I had originally was thinking to put this function in fs/ext4/super.c, but from the perspective of keeping the MMP code in the same source file, it probably makes sense to keep this function with the other MMP functions. > > { > > if (sbi->s_mmp_tsk) { > > kthread_stop(sbi->s_mmp_tsk); > > brelse(sbi->s_mmp_data->bh); > > kfree(sbi->s_mmp_data); > > sbi->s_mmp_data = NULL; > > sbi->s_mmp_tsk = NULL; > > } > > } > > > > Basically, just move all of the cleanup so it is done after the > > kthread is stopped, so we don't have to do any fancy error checking. > > We just do it unconditionally. Cheers, - Ted