Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp267151rwb; Thu, 11 Aug 2022 00:43:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7vqzY4XO7rqlfxCZ0DbidLrfQXzGJfWlwK13pEMLq5Y1f2KugYGKGQImzQC3VA5UNPxWIP X-Received: by 2002:a17:907:9688:b0:730:f098:86d0 with SMTP id hd8-20020a170907968800b00730f09886d0mr20319569ejc.60.1660203787230; Thu, 11 Aug 2022 00:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660203787; cv=none; d=google.com; s=arc-20160816; b=qIMs1B3rkYc8Eh+f7uNsiPDpaWX4fBDhBbYYarZ3qVAZj1hS4/V9ME2ykJC8TCFvUr MSK0tGgcz5OZvK68cNRilI/pU0MbhcVq4hF6Mgl2h83leau8QBH6FHwyt0ku6bEpTiky SubRa8RRcp24HCt+bps3AP8yjl5rFxXfw5PsftIjIDXRydKJEzZSn2iGAnwk4GB522sK 6xzoI9d8Fwph9TB8Z53DCFtfy7Vcwy4xgsvB626E0sBdhkdbI6o5VeA0KWxcvTLtvXpr vnEVnUJy4oiU0Put2/bGPqa+SxvEf6bgqZGVvZlfhFAySBRQLBx6rZTfPd5J/Jxvx7q6 ZijA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=qux8A0sA+sRKSR+Gjy1mN83aMu0GG4Ao2LZfl91jnBw=; b=lqHtfP3S/X1mMexBVuLipOijhaWpYqEfTADBXCizN+1mWsT6XjBeKa/HSB7nU0JBjN TCQQxI4fqRnbchL7gc6IfbyLbJqP0zwLx1OuWUApPxt9zmSn2fIGMY6rWnVTW538ODOD PC2uPHveiwx28/UOglSLkxWu6QdVpZTpDawboK90OoX3xhiR+4Y3GIkM5xJVuLg140NO kLoZQXb3uQaLgCEZDIpovHevirFpemk2AGcv2OD0Yh4f8KLGXQrBgi67piK/rYwP0nWu 8104nsiRcc4Up0eoecRGMCXmm4FvM3mDu8dfI2UWAC0q0P8zVOhn0Yica1IZN6+Py0Df 7/xg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a170906111500b007308707489dsi5136131eja.662.2022.08.11.00.42.41; Thu, 11 Aug 2022 00:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234237AbiHKHS6 (ORCPT + 99 others); Thu, 11 Aug 2022 03:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233563AbiHKHS4 (ORCPT ); Thu, 11 Aug 2022 03:18:56 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9071779A63 for ; Thu, 11 Aug 2022 00:18:54 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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