From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5C7DC43217 for ; Sat, 12 Nov 2022 10:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 732696B0071; Sat, 12 Nov 2022 05:47:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E2316B0072; Sat, 12 Nov 2022 05:47:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D2476B0074; Sat, 12 Nov 2022 05:47:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4EDA76B0071 for ; Sat, 12 Nov 2022 05:47:23 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2B12E16053C for ; Sat, 12 Nov 2022 10:47:23 +0000 (UTC) X-FDA: 80124463566.17.69D8D73 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf24.hostedemail.com (Postfix) with ESMTP id D790D180003 for ; Sat, 12 Nov 2022 10:47:21 +0000 (UTC) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N8XMC5ccbzRp3V; Sat, 12 Nov 2022 18:47:03 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 18:47:17 +0800 Received: from [10.174.179.24] (10.174.179.24) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 18:47:16 +0800 Subject: Re: [PATCH v3 0/3] Refactor __kmem_cache_create() and fix memory leak To: Christoph Lameter , Pekka Enberg , "David Rientjes" , Joonsoo Kim , "Andrew Morton" , Vlastimil Babka , "Roman Gushchin" , Hyeonggon Yoo <42.hyeyoo@gmail.com> References: <20221112112055.1111078-1-liushixin2@huawei.com> CC: , From: Liu Shixin Message-ID: <468b9657-df1a-24a2-49fe-18377bf59651@huawei.com> Date: Sat, 12 Nov 2022 18:47:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20221112112055.1111078-1-liushixin2@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668250042; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dWBAiquKhzliCkSV635kvk5EaGiYudqTJ4Dvk1y6m8o=; b=Tn03pt0QIOFjIW4aul9RiY5aezMPKr7Qnlt5Qz6fY30MRAIV3VmqxgiJIS6/fZZ4QBeABS 4g8wDXuofFKoXHugLkZndW+9CIWevKn7YqsA62fxrvgkdXWHwJsl+yVG9ThuhX6TneAasI 1KqHcPydeDCAQwn3fhjObZwaUOoc88Y= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668250042; a=rsa-sha256; cv=none; b=RJc6O5wypRvql+kUk6pp0ADBR4LDug7PUPLg1AQMVsfHSRrfPThAMROdNnvq3/nzScdinQ V0nUA85IcKDBGrPR71gYds84J/sgiq8su9y+Qhu/WTqNZOk5XooQXIuVclRLZnHSzBYNtb PFuTVe4cGDSgWcPy8pZfw31fGm8gVSg= X-Stat-Signature: sts6s8h1dm4tajz8pthtxte6mnwnkofc X-Rspamd-Queue-Id: D790D180003 Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1668250041-599510 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Please ignore this set of patches. I need fix and will resend then. thanks, Liu Shixin . On 2022/11/12 19:20, Liu Shixin wrote: > I found a memory leak of kobj->name in sysfs_slab_add() which is introduced > by 80da026a8e5d ("mm/slub: fix slab double-free in case of duplicate sysfs filename"). > Following the rules stated in the comment for kobject_init_and_add(): > > If this function returns an error, kobject_put() must be called to > properly clean up the memory associated with the object. > > We should use kobject_put() to free kobject. > > But we can't simply add kobject_put() since it will free kmem_cache too. > If we use kobject_put(), we need to skip other release functions. > > In this series, We refactor the code to separate sysfs_slab_add() and > debugfs_slab_add() from __kmem_cache_create(), and then use kobject_put() > to free kobject in sysfs_slab_add(). This can fix the memory leak of > kobject->name. > > v1->v2: Fix build error reported by kernel test robot . > v2->v3: Don't free kmem_cache that create early. > > Liu Shixin (3): > mm/slab_common: Move cache_name to create_cache() > mm/slub: Refactor __kmem_cache_create() > mm/slub: Fix memory leak of kobj->name in sysfs_slab_add() > > include/linux/slub_def.h | 11 +++++++ > mm/slab_common.c | 44 +++++++++++++++------------- > mm/slub.c | 63 +++++++++++++++------------------------- > 3 files changed, 58 insertions(+), 60 deletions(-) >