From patchwork Thu Aug 11 07:18:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12941208 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 565BFC19F2D for ; Thu, 11 Aug 2022 07:18:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0BDD8E0002; Thu, 11 Aug 2022 03:18:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBB0B8E0001; Thu, 11 Aug 2022 03:18:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA9BC8E0002; Thu, 11 Aug 2022 03:18:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9A4EF8E0001 for ; Thu, 11 Aug 2022 03:18:56 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 74CE01C6B67 for ; Thu, 11 Aug 2022 07:18:56 +0000 (UTC) X-FDA: 79786459872.30.A9636AA Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by imf23.hostedemail.com (Postfix) with ESMTP id 6934314006C for ; Thu, 11 Aug 2022 07:18:54 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R761e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VLyAV5x_1660202327; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VLyAV5x_1660202327) by smtp.aliyun-inc.com; Thu, 11 Aug 2022 15:18:49 +0800 From: Xin Hao To: cl@linux.com Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 0/1] mm/slub: release kobject if kobject_init_and_add failed in sysfs_slab_add Date: Thu, 11 Aug 2022 15:18:43 +0800 Message-Id: <20220811071844.74020-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660202336; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=qux8A0sA+sRKSR+Gjy1mN83aMu0GG4Ao2LZfl91jnBw=; b=2STxBRErg9jKmZ+aZQVZOYSSlqy487pmy93tCq73/y95aE/MmJpH4YKxf/6wZLrfWTCUDe esFPJgiLlAUBQPWzi1CEXoetc2LgHKcbH8J2NlLokbh9jnFDCIGaLr28GnkJ687QqUKwEb Z9W0RtGuQIiudCZKOJW/XNNhYznguW0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.56 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660202336; a=rsa-sha256; cv=none; b=sUsyfgod/h2k6bg3vKy1xDVu3XXGkXCDBw8+GgtRQT2wd1KlDH/AeMmEpHOPP/MWGLQbxo CmkgCTkF2HfUYUIWH65I4LmzAFfjQuu/V/XCbL1A3sec/W9jSSzE5fTnQU1Tgj6UbYKLdz irz7LyYkCgEvRA+4wxZRpz5injWGuTI= X-Stat-Signature: qw7pee9domn6zhniu6y6kghfzyg554a9 X-Rspamd-Queue-Id: 6934314006C Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.56 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1660202334-302151 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: In kobject_init_and_add() function, the refcount is setted by calling kobject_init() function, regardless of whether the return value is zero or not, therefore, we must call kobject_del(&s->kobj) to prevent memory of s->kobj is leaked. V1 -> V2 use kobject_put() instead kobject_del(). V1: https://patchwork.kernel.org/project/linux-mm/patch/20220811025258.68684-1-xhao@linux.alibaba.com/ Xin Hao (1): mm/slub: release kobject if kobject_init_and_add failed in sysfs_slab_add mm/slub.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- 2.31.0