From nobody Tue Feb 10 08:03:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1666319046; cv=none; d=zohomail.com; s=zohoarc; b=HvZOL4ItX44vi1C90L7zD38rFiC9PCo1NecrAAmvHWyofMRHckeh9kLbTYmfBj80X/HknGg4V0MfjADRhbsPB054JZphoyJQ1bp+FiAf9WFTcx7c9eR58D/kYaJBye5MoxVTqZ3kQAbffu/Y6GjdRt2WQ9Fw0I9JgoQx4+7DJJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666319046; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=xzMFxLeFKUbQzHCjgeZFy2Z3JsN/mOjM/Yn4m8OkMjM=; b=FUahfrhaYuvWNdDXQ88M79Z1LADjjTDT+npMQ6QMMS9Bh3h3TM+zLl/WiZFHX0DpydsEzsRd8v7+bwa2ZbgcgLY6hGrGCtuffpEC+e+XN+EMAvXEh+rH1Wpv12olmlalCbdDOuswQJA/qkgyq3Qo5y0XGK9Zn2oxHLcvm5oVAWo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666319046799294.2295847387609; Thu, 20 Oct 2022 19:24:06 -0700 (PDT) Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olhhd-0004cZ-Al for importer@patchew.org; Thu, 20 Oct 2022 22:24:05 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olhh5-0004WG-6O for importer@patchew.org; Thu, 20 Oct 2022 22:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olhgz-0004VJ-7q for qemu-devel@nongnu.org; Thu, 20 Oct 2022 22:23:25 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olhgv-0003WW-5L for qemu-devel@nongnu.org; Thu, 20 Oct 2022 22:23:23 -0400 Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mtp6h64dWzVj27; Fri, 21 Oct 2022 10:18:36 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) 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; Fri, 21 Oct 2022 10:22:45 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 21 Oct 2022 10:22:44 +0800 To: , , , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH 09/11] ocfs2: possible memory leak in mlog_sys_init() Date: Fri, 21 Oct 2022 10:21:00 +0800 Message-ID: <20221021022102.2231464-10-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021022102.2231464-1-yangyingliang@huawei.com> References: <20221021022102.2231464-1-yangyingliang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.188; envelope-from=yangyingliang@huawei.com; helo=szxga02-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Yang Yingliang From: Yang Yingliang via X-ZM-MESSAGEID: 1666319047994100001 Content-Type: text/plain; charset="utf-8" Inject fault while loading module, kset_register() may fail, if it fails, but the refcount of kobject is not decreased to 0, the name allocated in kobject_set_name() is leaked. Fix this by calling kset_put(), so that name can be freed in callback function kobject_cleanup(). unreferenced object 0xffff888100da9348 (size 8): comm "modprobe", pid 257, jiffies 4294701096 (age 33.334s) hex dump (first 8 bytes): 6c 6f 67 6d 61 73 6b 00 logmask. backtrace: [<00000000306e441c>] __kmalloc_node_track_caller+0x44/0x1b0 [<000000007c491a9e>] kstrdup+0x3a/0x70 [<0000000015719a3b>] kstrdup_const+0x63/0x80 [<0000000084e458ea>] kvasprintf_const+0x149/0x180 [<0000000091302b42>] kobject_set_name_vargs+0x56/0x150 [<000000005f48eeac>] kobject_set_name+0xab/0xe0 Fixes: 34980ca8faeb ("Drivers: clean up direct setting of the name of a kse= t") Signed-off-by: Yang Yingliang --- fs/ocfs2/cluster/masklog.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index 563881ddbf00..7f9ba816d955 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c @@ -156,6 +156,7 @@ static struct kset mlog_kset =3D { int mlog_sys_init(struct kset *o2cb_kset) { int i =3D 0; + int ret; =20 while (mlog_attrs[i].attr.mode) { mlog_default_attrs[i] =3D &mlog_attrs[i].attr; @@ -165,7 +166,11 @@ int mlog_sys_init(struct kset *o2cb_kset) =20 kobject_set_name(&mlog_kset.kobj, "logmask"); mlog_kset.kobj.kset =3D o2cb_kset; - return kset_register(&mlog_kset); + ret =3D kset_register(&mlog_kset); + if (ret) + kset_put(&mlog_kset); + + return ret; } =20 void mlog_sys_shutdown(void) --=20 2.25.1