From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from verein.lst.de ([213.95.11.211]:57286 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753929AbeFKGQA (ORCPT ); Mon, 11 Jun 2018 02:16:00 -0400 Date: Mon, 11 Jun 2018 08:23:54 +0200 From: Christoph Hellwig To: Chunyu Hu Cc: viro@zeniv.linux.org.uk, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] proc: add proc_seq_release Message-ID: <20180611062354.GA32641@lst.de> References: <1528573884-9133-1-git-send-email-chuhu@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1528573884-9133-1-git-send-email-chuhu@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, Jun 10, 2018 at 03:51:24AM +0800, Chunyu Hu wrote: > kmemleak reported some memory leak on reading proc files. After adding > some debug lines, find that proc_seq_fops is using seq_release as > release handler, which won't handle the free of 'private' field of > seq_file, while in fact the open handler proc_seq_open could create > the private data with __seq_open_private when state_size is greater > than zero. So after reading files created with proc_create_seq_private, > such as /proc/timer_list and /proc/vmallocinfo, the private mem of a > seq_file is not freed. Fix it by adding the paired proc_seq_release > as the default release handler of proc_seq_ops instead of seq_release. Indeed, thanks for the patch. Reviewed-by: Christoph Hellwig