From patchwork Fri Oct 21 02:20:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014207 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 aib29ajc255.phx1.oracleemaildelivery.com (aib29ajc255.phx1.oracleemaildelivery.com [192.29.103.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27417C4332F for ; Fri, 21 Oct 2022 02:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=tTZfC3SjVnsZbcasKk4wwhSy2LkzTd4PkfYJNQYn3dE=; b=iRBvSz6VEKdRB9jbsG3fcl6sRkUnPZNhPmadyFzW4wJPlA/OpxtrczRhIw6fhKI/tQDijkcOfSX6 mEQ3zwyzY+7EyptSTFTbtBR4m8ZgEaR72xXLL4bG1I+/1duahNvwvu+SAUuHLLbAks4Er+iKwliE 03paOgGXgUC63shnncB3ZIYQuoQQoUgSwuF7YVC8Meaz83KX+/ZDkNOJbf5XvLHdAB9o25ra2Fx+ pVSa81cXzKrqLKhUvBJLMJwS79p6LEjMX1f2IbazkK9UYFM2MyAmt0NHr1EkPbPZ5DfYeZPTzmtv C44NhMYoY4lBuBXQYaRRCMVXxWQnO9TTV7itRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=tTZfC3SjVnsZbcasKk4wwhSy2LkzTd4PkfYJNQYn3dE=; b=fUBmQWFpukLowvZbKjmqEDOTMvkY0YHMGPt1iovvRmwoWVvQ3kAk/Un9kY+yNA20LPSn/OpULDqM 2aOasRKsK9jwSgJk2APAuXp5OehT32AcrgS2N9irC/5ueenO0LJhQNC7FY6yHTiKsPHKNSB5LlgJ 8BuyHMSJZvGG9x5dYGceQ4pGwi0D79KypvUAuZ1AlQfzZ1eWUFmFEM7942ls0P/P1Zn9IAkfiyhK Jo4wW0fuM0czklnc+OuyT6mL8R8JHYHT2nqRi1a7VHjmRX7ew4XZbyDEXdEZ7kdn8qSdpdoLQQrz xTDyFe/hbv/R0+zA55LozQkAuTSWn8GvYVejHQ== Received: by omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK2005MPZYEAE90@omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:02 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:52 +0800 Message-id: <20221021022102.2231464-2-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 lowpriorityscore=0 clxscore=23 priorityscore=226 mlxlogscore=771 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 01/11] kset: fix documentation for kset_register() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: O3PX0XqMVDdY3SDUHkCQsP9Q5xRUXIwP X-Proofpoint-GUID: O3PX0XqMVDdY3SDUHkCQsP9Q5xRUXIwP Reporting-Meta: AAFEKcQ8UBbaG/LbfAg6wNx6jrrm80gKaG4bC4wCYzffaCJR4d9eGPI9F+fpLC4C 1dFQ3wRcF15HgthtxC3t/e62Qc2/CscXcpJVJFQXxi1zuHhpsrCTNum9lHZpPT/m Y3DkAR9Z6qsuYu2I4g5QFJN2Z3jW4TaA05+Sw31/5qgys/z95uJV9G2InHOYly+C Pv5XyRSawVmDQoxLSIOXkMbsx4vmJ/VTJ5SGqM5Ni6NgNBUWBVKF5GSFJEapK18y hIkt/hbn+VDBP6TotkNLo9XLmkSHGU5ZWWvmzDIlQM8qP/qfo8WUxFsVcgPtGIQa s11AzZ3++lizteRxcnI/3bYXcpMwO3fOhUNNHSwX0QI9s7c9VdI2AYn59cDGyb3P OvC1TrzC+jmZrj0xRcgVZ1cJI71Ma7IRPdh6EqRU4ngoGiRUduWqYfJnEe/MZqh7 58+hHGdyFTs1DaW7uyMxvMGHE0odW75cidThRVZ0vUWz+xG/S4uFH6vhU5C+9eMD iQAHPXzft98eOMLMeJJLSvDXpmYKKBPH4EZ54fzry5xc kset_register() is currently used in some places without calling kset_put() in error path, because the callers think it should be kset internal thing to do, but the driver core can not know what caller doing with that memory at times. The memory could be freed both in kset_put() and error path of caller, if it is called in kset_register(). So make the function documentation more explicit about calling kset_put() in the error path of caller. Signed-off-by: Yang Yingliang --- lib/kobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/kobject.c b/lib/kobject.c index a0b2dbfcfa23..6da04353d974 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -834,6 +834,9 @@ EXPORT_SYMBOL_GPL(kobj_sysfs_ops); /** * kset_register() - Initialize and add a kset. * @k: kset. + * + * If this function returns an error, kset_put() must be called to + * properly clean up the memory associated with the object. */ int kset_register(struct kset *k) { From patchwork Fri Oct 21 02:20:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014201 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 aib29ajc248.phx1.oracleemaildelivery.com (aib29ajc248.phx1.oracleemaildelivery.com [192.29.103.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86A7FC4332F for ; Fri, 21 Oct 2022 02:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=zFveVdAmxbJoy3lP0CxUnTe5MlcjJr1wqy0vZcx5dnQ=; b=vKdvE3WKD93AenRPCaGpiM8oFOGUXEycpDpLRObIdGSe7NcaTO7U3JpfbaLY2e+km8Zc6tjICYlQ paYT5V3IUJ8MtFUmc4AQ63T70bRrxBEN/mt4n1K9ZYmslQghB+euqQiJKTt75mDSgikqUq2L6NY7 3P9Wb7SpQCs0NBD7sg+sY8Qlf5GewpMn3diuoUvotyM8hFxTPEUJdxdnFwVHImfiQMBDnCOBm6dn 4VM6hZdfLWM/NsxJz0JtEH7ySZdQdyqQve8G0cGa4hMx2apBKZQRETtdzUE35W6LET6fbsHXbub7 6bbsxsZuHliynMvq6ln+UlrgEjvofZkljbVseA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=zFveVdAmxbJoy3lP0CxUnTe5MlcjJr1wqy0vZcx5dnQ=; b=K0LVXcTiedxPQbXgDEV1m7mTgeqBkrtZ8mjutJOV/4sNOYwoXFjNZsaHBZTn3qFQe4zNkOeBWvsI lKRKfC0FnCmKLqOL71ckG5uJeGFIz9hPrcgeAxJCWNjggX3RBaSSIxWLsEonIN1yMffWsm6YK/fy Y9DKxAtxc2qTL7B1+bUN8oIODlqi/ERU7yN9thhTyshKYh7wNJPBlafRkn+4fsx8V1QrqZNaPUwr 3bwD+gDrAXzWSNzNM8tKo3hKZcyE0LZGhNquTR6EWMLb6yl2kFZA0m01QXiqeMEfgHGpqX0UDvFC B2spkmhCWmQ+FDhY7mQagIsS59L3BTfXES5u0Q== Received: by omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK200A8JZY4HD70@omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:22:52 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:53 +0800 Message-id: <20221021022102.2231464-3-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 lowpriorityscore=0 clxscore=15 priorityscore=159 mlxlogscore=810 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 02/11] kset: add null pointer check in kset_put() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: 12Fm14NVohcr8iv7XPotQtIrbeAbZQjP X-Proofpoint-GUID: 12Fm14NVohcr8iv7XPotQtIrbeAbZQjP Reporting-Meta: AAGlgu0ENsCPw8rh3Kf8s6PW7qCmBFuxELGMl2io4HguAuPCuSj0ejCx87uj89dB d3fLfiYyG1q86R7ShRvHIsTThKZgdk3kTxOyZAXgThD83cTpE8764H1tNPpxRy68 +OVdmVokB02yCZWvdtXd6RzvcR++YFlKonaX4B8qsMQAxnausxskkKro8HWgeCWo 7urkeC4sWsWXiY/68iYEMcjBVF7WqrarczcIK+v9vL1y4LlX+3UEzdL2Ao90+CE3 1xyQ7AaGkEzmqOkoF2A9/EXRhLG+EbGfDw7YbrOMpcDq/dBCKBxQN+JL4f8iJZtO TfNnvj67a9odb+36qpkcVf56/8zf0T/aHMPpR5LE7jC8g1XINyMskCVNaXst7Let 0JTHymSGUQBfZx9QtSp6ENKa5Rd+SvhDsCz/4w3E6+JZdXVbUNfxoKTKA1Lomq0Y VCCqBPChFVpsMiXFlNZVxHhHuaPhg9VEqyMwqBlTJseMox51Rrn8BiBWk3drWwh2 wEtfzAtqPYjOyoICHD0HVlPODAwcxPjvvW07NP8aoSdA kset_put() can be called from drivers, add null pointer check to make it more robust. Signed-off-by: Yang Yingliang --- include/linux/kobject.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 57fb972fea05..e81de8ba41a2 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -195,7 +195,8 @@ static inline struct kset *kset_get(struct kset *k) static inline void kset_put(struct kset *k) { - kobject_put(&k->kobj); + if (k) + kobject_put(&k->kobj); } static inline const struct kobj_type *get_ktype(struct kobject *kobj) From patchwork Fri Oct 21 02:20:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014204 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 aib29ajc245.phx1.oracleemaildelivery.com (aib29ajc245.phx1.oracleemaildelivery.com [192.29.103.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8498CC4167D for ; Fri, 21 Oct 2022 02:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=LFPfh+AqtBp4D/fSpCdqEAPYuFmr+oRuD3e5SttW160=; b=Ae73ajk4YrpxHC/dk+xtMAVb8QCuxXW8txXN6iZiBqhic4Q++3MZCqOnj+S9wtgKQwmG8W78GXKr JCShnSdFvtdpP6jkOrPfxF0svET/TMAmb7YPD+JmttOCzNpd2bUM3U50CIL54rrCvZyATO7CQCTw gFoHXz01tijBRQBv0y39lG9SsnwbkogxDwoJiPS8nBi3ooJUHKS36Tk2cuCr0FrBk78hQalCbJ2Z 21L7L/APu7QAdRFhAtCB/lhaxN0PspG370v7Jqx+DdyzE6RfK6wq7NGFgwhpJP88vlGmrRgF1A/C oP/WLC2Z7jzBTaaZZgq504QHoPUKPuJ8WxwNdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=LFPfh+AqtBp4D/fSpCdqEAPYuFmr+oRuD3e5SttW160=; b=OYw/6Avc1U66eP34a7O5m1jGnYqJr6dj2YUReRBP+DBUiuL5FSfefnpKepdUz621wddPYxcjx9Ve x/NjZQ+3RSBOArK94sE8q1kj+ADvVezTmRx0KiZac+OFn/E7WX+zfdqPHJTjsDsJUsHthxcGldog y0u2M+UlrsLO3ggjdwk0npi4NLE2bqmwII8lXOcO1rAYrlkk/tnlFsiBcMYh8gR/anW/8xD1RFiD BBRva3tu5hDOaYHHk/36ahTgVjDApwovZHBXfUdmlhQWLafdxCmrHan7a3ASwmCoj1oX+2E922za PRb3OcP2SY+3EkPbHpSgFpkMaS2yLa+BYdZ7pg== Received: by omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK200KEYZY87QB0@omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:22:56 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:54 +0800 Message-id: <20221021022102.2231464-4-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=159 impostorscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 bulkscore=0 clxscore=16 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 03/11] bus: fix possible memory leak in bus_register() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: 5G8mAOrNv7VGe8EKORh_8wfqBiLDz5eR X-Proofpoint-GUID: 5G8mAOrNv7VGe8EKORh_8wfqBiLDz5eR Reporting-Meta: AAGWMax8bsk4+M13KDZvuGecUd8eqy9Eo45iq2/xXP5UMLwZk0DhiqOE/222qW+x EfHcPk9Po8acPLf2cjIm4CNvg+U5iLXO2WTfb4agVf1r6//idXXRX089zjojZ6E/ +kStqBJgTvfH7e796ljXIjSxIRw2ZuihftrkOwIluelLpCjM6FrRiSWETvr8q5z0 zfJkm24hhNhBIlnx6aUd6hBU6HLF+sh7M3SrZh1QHAtPt+3eFwBbJaBztyM1fvMe gkC5Zj+IlXFdXerD3TccjGzqhtiIghqU2FaipTWg1drk8mcqpeM0uZw7OrmQmyBK F1gDptnvADgl5DyX/LRxtNvqcrrL1hJ839LRCO1YSp5+3+pWt5VFyuQrfazkppJH 7jq6xOyjL2zDwCF07RNMQVERqiIu6301IZ1P/uZa2QQCrvjrpkpEL5/ZIR1qBvW6 nql5Pd6ebqSjOCJJvH9bwt72XaRnwURxmdKiaZcZIK79pzVijVhAohgS/Nu865Ge YX4Wyj587NRH5WfaEsuC4oPkJR+zpTP5PXpnOahJnLBT Inject fault while loading module (e.g. edac_core.ko), kset_register() may fail in bus_register(), if it fails, but the refcount of kobject is not decreased to 0, the name allocated in kobject_set_name() is leaked. To fix this by calling kset_put(), so that name can be freed in callback function kobject_cleanup(). unreferenced object 0xffff888103bddb68 (size 8): comm "systemd-udevd", pid 341, jiffies 4294903262 (age 42.212s) hex dump (first 8 bytes): 65 64 61 63 00 00 00 00 edac.... backtrace: [<000000009e31d566>] __kmalloc_track_caller+0x1ae/0x320 [<00000000e4cfd8de>] kstrdup+0x3a/0x70 [<000000003d0ec369>] kstrdup_const+0x68/0x80 [<000000008e5c3b20>] kvasprintf_const+0x10b/0x190 [<00000000b9a945aa>] kobject_set_name_vargs+0x56/0x150 [<000000000df9278c>] kobject_set_name+0xab/0xe0 [<00000000f51dc49f>] bus_register+0x132/0x350 [<000000007d91c2e5>] subsys_register+0x23/0x220 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Yang Yingliang --- drivers/base/bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 7ca47e5b3c1f..301b5330f9d8 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -804,8 +804,10 @@ int bus_register(struct bus_type *bus) priv->drivers_autoprobe = 1; retval = kset_register(&priv->subsys); - if (retval) + if (retval) { + kset_put(&priv->subsys); goto out; + } retval = bus_create_file(bus, &bus_attr_uevent); if (retval) From patchwork Fri Oct 21 02:20:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014209 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6FF62C4321E for ; Fri, 21 Oct 2022 02:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=lEJGt0NIZ4HFju9VZsWGdn8zPFWgAqsQlns99LkFCA8=; b=vt3898MkAcNlR9nISGOzkAjTC57QFkHXD9LoxOXOhMu2vxYA4Heg9zH5XRKsF5//fp3XhAzZmWjT Fsg0t60PG/OVdpHGHd7bcOC3O7OM1XtAA0XVHGcQ4ILS2KZMIjkR+TGD6/Hu63wCo3TNIN1/FVo3 vJRrI+cxSBiHuNzk3SZ6v78RPD02vtmvBaWswmlzRkwqj6CiJhM+7of9f5IU8cEhuXijEf+HtvoQ BRZ9uJGtt4ZT/Nz2GPqyzfR9cBqyhnM5o4SnRag1CjGqk/BZxrUuKbiAAMvam+X6/cGUomrhV7iO d9lNgQr3wHmdJVkvjKvPgVGBTHlqJ28Ww8XlFQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=lEJGt0NIZ4HFju9VZsWGdn8zPFWgAqsQlns99LkFCA8=; b=nAdloEKQD35v81/w+ripL2XNB9MjW6GZeqmwVr0kJoFaD6UMwz78yHQhAfCQKXy1SfdowXtWJYv+ ACkGeG88ngbcwFrMyx7/tQBgWuXGtqdBuW/Ih3tlTDzZqjOYuXtW7bijtipU+EN9pK99WriG1j7e 9qjnQ8IwZt+1DuxW0z/qRfGsRZBOPPO+KTBddWBylOVaG28pkakDXFeyN9+lJQibevW8i0GeGynn Wnwy+jJSNitwHHDWFUvd7aSFG86c/nbG1XghuU1ah2xcuW1z6yq3ecwckSrqcmqanlrxoK9WyQN8 33VM/LyVJsMQbaeID9PwgZXYlPqdWrJXmw0XHg== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK200GX2ZYFNKB0@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:05 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:55 +0800 Message-id: <20221021022102.2231464-5-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=226 spamscore=0 malwarescore=0 clxscore=23 impostorscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=952 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 04/11] kobject: fix possible memory leak in kset_create_and_add() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: Xo6-ACIn6yJR26KbFCHU8oNyV5h8w2iX X-Proofpoint-GUID: Xo6-ACIn6yJR26KbFCHU8oNyV5h8w2iX Reporting-Meta: AAHT9m4BIahXJxJNeD4S1FXEmiBtO2wCBUhPljmKFmaW/kaqUYwylb5oUCfALIkQ dreHlAkGb++jQppXC8/myxBMKCqIPxYjxnwEvqMtSWkdZ9lduUUhGqWxWkCTJmp+ Rlq80LqeLzAbDinfoqDcLrgItnPRCslAfHKGULED9U6R4XRjOuedArGelulT9Uhc 8AV0dNDpIn0ZojVm3vRoIi9JPjcm912i9fTmpPDjsUVU3UINeqnEAWlhiolTeSZ9 ZtDhlO3vNWjA7N2CXQUi5r7HXMz7+qnEa5c+Rf8m6zF5VNZVYjZklPxYbKpoI8kQ ZZVB3pXloBxbh9Gh6lzc/qvvqIk5moChJWhghuzbf/wa9zLyYs6IK51Tu7rcmq/n ij+0UHTR8DOtmI4SzNyIBj16eolv25rkn0feq12+tVCKfi6raNKL6AcrOdhW59ct UG8l+snNtu1SaNI1fGJlguFS1rIcJPOK/FzZMZSZJNAjubIlB4JgKQ3NB8ntLzAF JvlbNLsFU2evOdl888wQVOe2WhiqT43IpkWWmCy2KIMb Inject fault while loading module (e.g. qemu_fw_cfg.ko), kset_register() may fail in kset_create_and_add(), if it fails, but the refcount of kobject is not decreased to 0, the name allocated in kset_create() is leaked. To fix this by calling kset_put(), so that name can be freed in callback function kobject_cleanup() and kset can be freed in kset_release(). unreferenced object 0xffff888103cc8c08 (size 8): comm "modprobe", pid 508, jiffies 4294915182 (age 120.020s) hex dump (first 8 bytes): 62 79 5f 6e 61 6d 65 00 by_name. backtrace: [<00000000572f97f9>] __kmalloc_track_caller+0x1ae/0x320 [<00000000a167a5cc>] kstrdup+0x3a/0x70 [<000000001cd0d05e>] kstrdup_const+0x68/0x80 [<00000000b9101e6d>] kvasprintf_const+0x10b/0x190 [<0000000088f2b8df>] kobject_set_name_vargs+0x56/0x150 [<000000003f8aca68>] kobject_set_name+0xab/0xe0 [<00000000249f7816>] kset_create_and_add+0x72/0x200 Fixes: b727c702896f ("kset: add kset_create_and_add function") Signed-off-by: Yang Yingliang --- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kobject.c b/lib/kobject.c index 6da04353d974..e77f37200876 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -985,7 +985,7 @@ struct kset *kset_create_and_add(const char *name, return NULL; error = kset_register(kset); if (error) { - kfree(kset); + kset_put(kset); return NULL; } return kset; From patchwork Fri Oct 21 02:20:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014211 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 aib29ajc250.phx1.oracleemaildelivery.com (aib29ajc250.phx1.oracleemaildelivery.com [192.29.103.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A4D7C4332F for ; Fri, 21 Oct 2022 02:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=vKOew3c2fLe4+sExGmmBEDPqfDuiIMtQ7nwbS6sb824=; b=D4XVu4kTmO6wvfvW2HLNLl9tdXiORH36fNrsYcNMECYNP5VgvJfxkJZMmzEMXdx/70t2M1dlp3V2 FsdX0bRo9DiTzz5AqEeG9PbI0caywMgnvrS24Vn/dwRHHtM+WZvU83qFTeE1Am5F6mNrbkVGeFuu YahpLuMwXV4XFEhVeLDwj0ICGapKzOoRAnTUG+L+bYafPPTD8GGmSzjno3siXf6Q3VlJDhxbzo+l hyXVaZO1DUy4gV2RFLooxxyCt1Mi0Eoa8Bf+/aqFpmk5gG+xaOCc9+yRdlevk6JN8IXH3bCkKgMT T4icex9AZuEsDAP8Kv0AKbvy9/HCVsk4Ykdl/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=vKOew3c2fLe4+sExGmmBEDPqfDuiIMtQ7nwbS6sb824=; b=GnHCtsDdGG9Ho17dBuhTU+kHLEdCy2dTPBvtpHADU+8Xyet+wy1rgK/ezBJf4tSHONvznt9KJ+uP FkpNKra8zhDC7Iahk2FBlQ5oquBTtihJZJi/65Iy4gkBtjm1XEgcV/ikNnQOxJowd+Tc7lCKKN6d l4mcD0L39DGGJ2c2j/yu9DRqx01Fn3H8Yjm6cymQbY8HwfIAIPHcIZTKr5MKf5OvvTK/vnlxPe3V pv4nhL0oZ2nSKMzfti+K0USDjcS7lGsVAxCkmXQFHDdcUUcQmb2pbguVKdleXMCT/C6JUIwVWtlL rya6hyF+LdzxMEkkScMQEoEqr0rpruBZqNkOGg== Received: by omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK200HUTZZ5DJ10@omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:29 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:56 +0800 Message-id: <20221021022102.2231464-6-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=251 malwarescore=0 spamscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 clxscore=91 adultscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 05/11] class: fix possible memory leak in __class_register() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: IcXKm6D8iqfGnBR-K3BxNB2bI8dTYSpq X-Proofpoint-GUID: IcXKm6D8iqfGnBR-K3BxNB2bI8dTYSpq Reporting-Meta: AAG6Wn39JUzNg/QLJhQCMkSX1qqGJEl1oPOM/Aly/+sTnjTrLGtbqfAEmM0+NuH1 Bt+zM0ATaMbYkKGnrqyvVbBM0pJEYCqoLV/hEUhh/2UJhtVBjJVv+Nf4D2S3wl7p /bIF6tGoTCvwRywvpmUOoQQ7+HdpV9LY13rh7/XcDw1gNDguJpfbyBJ83oTk7eGt ZRCqFcAv5D4Tr4E3n+RbogGVbIux/2wjiG//46HtV+HpH9NT5Y6gdTqMdx56ejzp Beij9BFn06n4yMxmF6mvNbVY08x+SdbJGgO35Tt/60BF3lHdc8p8HcuKouNWQps8 Lt/VU5rYuMJbUaKO82MGfWCOxrUyKtR8tw7gpoYsgCQOn26Ju7phLWF3j+YVvB6h Jdj0/gX6pbnxkQIYdY7niFKNXeZ7w+3e2wqNuO00l5qdBXhwzfrM2/Ja2xdPRQDj xeIv5Gre/NcsdolWwFuAaeTa3V1iHbJS//W7lkfrPt+a8rZBFemTzQ3YIfGrptMS K/BGDiiyAjckfPZM77laYlLUAiZZAJnryGhvRMj44iA6 Inject fault while loading module (e.g. pktcdvd.ko), kset_register() may fail in __class_register(), if it fails, but the refcount of kobject is not decreased to 0, the name allocated in kobject_set_name() is leaked. To fix this by calling kfree_const(). unreferenced object 0xffff888102fa8190 (size 8): comm "modprobe", pid 502, jiffies 4294906074 (age 49.296s) hex dump (first 8 bytes): 70 6b 74 63 64 76 64 00 pktcdvd. backtrace: [<00000000e7c7703d>] __kmalloc_track_caller+0x1ae/0x320 [<000000005e4d70bc>] kstrdup+0x3a/0x70 [<00000000c2e5e85a>] kstrdup_const+0x68/0x80 [<000000000049a8c7>] kvasprintf_const+0x10b/0x190 [<0000000029123163>] kobject_set_name_vargs+0x56/0x150 [<00000000747219c9>] kobject_set_name+0xab/0xe0 [<0000000005f1ea4e>] __class_register+0x15c/0x49a If class_add_groups() fails, it need delete kobject and free its name, besides, subsys_private also need be freed. unreferenced object 0xffff888037274000 (size 1024): comm "modprobe", pid 502, jiffies 4294906074 (age 49.296s) hex dump (first 32 bytes): 00 40 27 37 80 88 ff ff 00 40 27 37 80 88 ff ff .@'7.....@'7.... 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N.......... backtrace: [<00000000151f9600>] kmem_cache_alloc_trace+0x17c/0x2f0 [<00000000ecf3dd95>] __class_register+0x86/0x49a It can not call kset_put() or kset_unregister() in error path, because the 'cls' will be freed in callback function class_release() and it also freed in error path, it will cause double free. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Yang Yingliang --- drivers/base/class.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/base/class.c b/drivers/base/class.c index 64f7b9a0970f..87de0a04ee9b 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -187,11 +187,17 @@ int __class_register(struct class *cls, struct lock_class_key *key) error = kset_register(&cp->subsys); if (error) { + kfree_const(cp->subsys.kobj.name); kfree(cp); return error; } error = class_add_groups(class_get(cls), cls->class_groups); class_put(cls); + if (error) { + kobject_del(&cp->subsys.kobj); + kfree_const(cp->subsys.kobj.name); + kfree(cp); + } return error; } EXPORT_SYMBOL_GPL(__class_register); From patchwork Fri Oct 21 02:20:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014202 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 aib29ajc249.phx1.oracleemaildelivery.com (aib29ajc249.phx1.oracleemaildelivery.com [192.29.103.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 791DCC4321E for ; Fri, 21 Oct 2022 02:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=9qMHzyWDLTiShrgxR1+3bOyrfToofGFuDVf7bqH+ozA=; b=DWdALEq5GOOijmJPl/EiQyCKpXCEDKq2VMZkDaWy5Ska3ubqTSfED9i0ScKQ9Nrg7xXT7/PA66qT MLesixbexo7zlgWiQWX512sTpxYHTEcE1wfLl+UqyMRelT0ey2P+6tL+r3YsZtZ5h2OTybskCf1a mYMfCUUpe73grjC8rHrYTgch8tc+M6i5zAWwQimf/UAWFfrsDWesFx4JwVUxrw8cg+J06+D+PyWA IsdGvgpd5baVqHdPMSDGSZX5TMkaXERcY6Fe4KhtQU7KypYYZyUPC13q1KryopbdudtjKRW/bUvo eNL9Jqk+D58wttl9OYyaAps2hhG0GXrBjJhwww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=9qMHzyWDLTiShrgxR1+3bOyrfToofGFuDVf7bqH+ozA=; b=ooNQ7UjEyDAp0oMiZBqWkUOtEecpnK9yugo+YTzmAMn73PL+4mZwuNqk03VWGOD3qmeVVkLrMlEc R8gQqlIL2OwFuvQDcVPANY1R9Fkz2Ptl+l/YOUBVoHrINeNg0dI7OdvSmPF5EtnyhPGOO7IxqUlw /kOXVMWqLZ/5JrVKxc9DVPu1cbH+T4Gnbzaiil4qUoItbIzrOqxFJF7K6kNNBf4JlvMgW9yg3FEz KpsEidIK6XZIVXavZe0E1YdbP315fNGdRpUocIkYldM6ji51gzg+GnVftVOV+rvLb+5d1JWiuH9v 7KWWICDbCbKKXqBxZr0NdorJDwZ4cW6IW2cVgA== Received: by omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK2003L4ZY7HB10@omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:22:55 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:57 +0800 Message-id: <20221021022102.2231464-7-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.255 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=190 spamscore=0 malwarescore=0 clxscore=25 impostorscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 06/11] firmware: qemu_fw_cfg: fix possible memory leak in fw_cfg_build_symlink() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga08-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-GUID: XVYhVBPuPJ1JXqgI-_invwtckVrEWsP_ X-Proofpoint-ORIG-GUID: XVYhVBPuPJ1JXqgI-_invwtckVrEWsP_ Reporting-Meta: AAGlgu0ENsCPw8rh3Kf8s6PW7qCmBFuxELGMl2io4HguAuPCuSj0ejCx87uj89dB d3fLfiYyG1q86R7ShRvRIsTThKZgdk3kTxPz0M/GoHPVkNux1Po+fCal7SCy/D28 gebPI45MtF+RvdqpX/VcKlLa/J3dLoAeoLKoH7/VlGHO3txL9ZKjMuwngk9cgOk5 +SBj16k+aWqc5NhQJuuKId0jI5MEUtyl5GsdMPwgpbAYmq3VcEu6wXM2Cr8itWhk PsrrZEIk/8dfDu95RMbkELh8+fyfJ1wM7MhCKkeVIbtSXGdw42q8WHEHMRf8du4Z RMgwUvF2zDyhnAvl3u8+Ks670x4SqPguW6j49zEJfXNEx2U9h5y/iBrLo6nsMlbI nt9z4OhZSYHvC8zY2uMJwQMU8VWTF9iNfXZJFZkEfv4MBK6X2FfXaR6l1umEtyAe HWmqArDpyJ2Cw1tulncFCPmvInIqAFahU3rdDIrXr5cOTVuXcNjzWRdA1EKHcOsA m5xM0I/GF2h4W9tjttNXc5BoI+/qfWaC+RMd5MUfUlCI 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. To fix this by calling kset_put(), so that name can be freed in callback function kobject_cleanup() and 'subdir' is freed in kset_release(). unreferenced object 0xffff88810ad69050 (size 8): comm "swapper/0", pid 1, jiffies 4294677178 (age 38.812s) hex dump (first 8 bytes): 65 74 63 00 81 88 ff ff etc..... backtrace: [<00000000a80c7bf1>] __kmalloc_node_track_caller+0x44/0x1b0 [<000000003f0167c7>] kstrdup+0x3a/0x70 [<0000000049336709>] kstrdup_const+0x41/0x60 [<00000000175616e4>] kvasprintf_const+0xf5/0x180 [<000000004bcc30f7>] kobject_set_name_vargs+0x56/0x150 [<000000004b0251bd>] kobject_set_name+0xab/0xe0 [<00000000700151fb>] fw_cfg_sysfs_probe+0xa5b/0x1320 Fixes: 246c46ebaeae ("firmware: create directory hierarchy for sysfs fw_cfg entries") Signed-off-by: Yang Yingliang --- drivers/firmware/qemu_fw_cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c index a69399a6b7c0..d036e69cabbb 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -544,7 +544,7 @@ static int fw_cfg_build_symlink(struct kset *dir, } ret = kset_register(subdir); if (ret) { - kfree(subdir); + kset_put(subdir); break; } From patchwork Fri Oct 21 02:20:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014203 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 aib29ajc249.phx1.oracleemaildelivery.com (aib29ajc249.phx1.oracleemaildelivery.com [192.29.103.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92739C4167E for ; Fri, 21 Oct 2022 02:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=1gwRjwrTndNYneoYKSzjAFm7IQx7lvt6QjZbNn6S3K8=; b=fAwBvbkaNIn/4cw69oNOdXWG9sF9w4PSZZqva6mFqJ47yImaADEaFLJf29NdfE6wuJz3yUbKXozj GuN74U7s5Fa8kAPTKTnrBsEX/eksJX0WdBnMjmvb5buU8ZY9Sk78ahMetwq+wTxmMnV2uokDmZjy 5DYwZkwT4wY8ZBK2rK+37IErhyHVFNJTeTgzy4Am4tSH9UjdntyRcQLvbygx7BrEEZiQsD4wGkQN wEFJ0eO8bMxR6yW5Ey1XCgy7sp+dqkVHwtSk9lXxl3vd1L23mU3oJeqGVUwa0gbL2F0F3KzQncB9 uBiUKXz8Jo6OyPVd8ETsIzSu08QB4w2LKZouLg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=1gwRjwrTndNYneoYKSzjAFm7IQx7lvt6QjZbNn6S3K8=; b=VjNe1knWSSx9sqXW0tMrQzHoLcsQRqi6w9GGv9ZIFabRnwK9SV1TmksykC08643JpzW/IUyoxSL3 XgpBqxQx58efq45MC6KeKRemGgNiguwufrxVIGGEPiLvekhYrSkPAmVRDpWxcen8g6tpbcZeLoZk s8Ej3Pmvlkt/ulcpxNPT4ZRfaH/aWN/3LlfkxILxukIHbAcRr/0hWRAdCrlCdDTNliYuk7uF6Q6d 3TmSFLbjvJLw/VbegldGFJr+z6vY6GNFkZavr9AbWvG2mECLnSidtUs+22qVA1W3dZ+5RurqyzpU rVwWjtlCkN1sincf23LLQCR1R/87aySHqkts3g== Received: by omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK2003LAZY8HB10@omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:22:56 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:58 +0800 Message-id: <20221021022102.2231464-8-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 lowpriorityscore=0 clxscore=22 priorityscore=212 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 07/11] f2fs: fix possible memory leak in f2fs_init_sysfs() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: -l-e5P5K2P9HPsArZSShHjpMKoFrR0TF X-Proofpoint-GUID: -l-e5P5K2P9HPsArZSShHjpMKoFrR0TF Reporting-Meta: AAEk8cI6SBGj400tUcrYr93EVsvdBu2aoIrafaXLZp7VP0Ix/eTZFBNk4P/YZn1n brB422vd6Tc/Xf4CapwFsR8EnZdIUTuV0zWwtvHMMfF8txzPYIk/XOg3TSnJsew2 dcwQqoJcoMl8Cby977+Sszo7wlygPcLxdvcUSW7Db22rBkOiPVki4b2QyKjwZnEa l4vD5T35U161s+WHwtf0zw5USEMjHupzIZIuWTDPauch+DQ+qJjbJ+eEA69rUiVp iZz7vvB6bKh32i+pCtiaZl815blPeYR05jxhasH8BJXVHBLpTCM3N6uLeGc2fQDW RJkrO2UWGYncLylcLPXpg1tZzvVzir1c9gbsxMjGe+a8yYDZmHKi+dnAuKFoivcj eeuJq/EH8ipv6n7ygPQ67oeWPa0evLUVc3YEYTjk7++q5v9yV40UJGg+5+RQUurt 6dCK9aeOFLhne5tvaqmjzf9cc9Dtm5dfElPTf+NvKKWoamKnAIjoQA7I12zcNlyQ 4SeT+qvBRRGwzlAaYYCDrhe7RkgFtfg4VSougV67UiM= 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 0xffff888101b7cc80 (size 8): comm "modprobe", pid 252, jiffies 4294691378 (age 31.760s) hex dump (first 8 bytes): 66 32 66 73 00 88 ff ff f2fs.... backtrace: [<000000001db5b408>] __kmalloc_node_track_caller+0x44/0x1b0 [<000000002783a073>] kstrdup+0x3a/0x70 [<00000000ead2b281>] kstrdup_const+0x63/0x80 [<000000003e5cf8f7>] kvasprintf_const+0x149/0x180 [<00000000c4d949ff>] kobject_set_name_vargs+0x56/0x150 [<0000000044611660>] kobject_set_name+0xab/0xe0 Fixes: bf9e697ecd42 ("f2fs: expose features to sysfs entry") Signed-off-by: Yang Yingliang Reviewed-by: Chao Yu --- fs/f2fs/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index df27afd71ef4..2ef7a48967be 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -1250,8 +1250,10 @@ int __init f2fs_init_sysfs(void) kobject_set_name(&f2fs_kset.kobj, "f2fs"); f2fs_kset.kobj.parent = fs_kobj; ret = kset_register(&f2fs_kset); - if (ret) + if (ret) { + kset_put(&f2fs_kset); return ret; + } ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype, NULL, "features"); From patchwork Fri Oct 21 02:20:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014208 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 aib29ajc254.phx1.oracleemaildelivery.com (aib29ajc254.phx1.oracleemaildelivery.com [192.29.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55889C4332F for ; Fri, 21 Oct 2022 02:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=NeOAvwG78rHJLvEg1egwz1eV+52Ia32p4j2uGLArlfA=; b=FL/EAXrKnpIENNk+KR6xip7se/mLBa0Y0YxBOZfbgE+25j7DXDz+UOgHmRZ5Et+0MJ88OEWoIEKk LTVSewr5z0UesPNFN9ATd7dzhRDU1YHP6QKyz68cbKluXxWaTV2Esd7AKR3QA8DMXmaZgmNh729a 0y9oEdMRzEFA6qqQIerZ8Pg14BZZrJaH+DbYUoA1mNb/TWwTNaFHL9ip5DVeDDxSJntdN/VXgOEF AXpdIhlG5hEVeKjinVsU2ydZ5+nXyFqXXSSMCSts7EN07p/SDPGXSf914j9JxMgsGaJuoAiGZ597 XZjBSslKYdFP5SjgqNsgRpfRpJp0jU9k/mFXKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=NeOAvwG78rHJLvEg1egwz1eV+52Ia32p4j2uGLArlfA=; b=i2UBkyAn9Rb6FaPjNMxaiWq/AVJdA37U+gYh6z3kkqpZxoA6gyv5xDRLgF0Yfva+JCWCrAFsNb4y N1y/gSUDrh2josX8IM4Uuwn/Kf8DJrLlQaHuMeSzG6vs/nv8Zi3WdBpTpHY+4WC4JhnfZ7z4Dviv AbPyyWsMSd7ZcW2LlvEOU9CtFhsYrP6ubDsdtb7HyK7Si39Ftw4jXsn34WRzxO+qMxS+oc5914o5 fVBE+sPnH1zGy0BgM5rsXDi3H5Vjc4qCSfZEyO0s2C3f13bXo3mifGlKsAxvoOqAruRK+JolQy3M 6cPIDtK88LwOsPwhndhb811jQNXJul3FafONRQ== Received: by omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK20094KZYF5GA0@omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:05 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:20:59 +0800 Message-id: <20221021022102.2231464-9-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=233 spamscore=0 malwarescore=0 clxscore=26 impostorscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=949 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 08/11] erofs: fix possible memory leak in erofs_init_sysfs() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-GUID: TJmuXEsCBljUeT9fLhUpHfu9fB6ApE0I X-Proofpoint-ORIG-GUID: TJmuXEsCBljUeT9fLhUpHfu9fB6ApE0I Reporting-Meta: AAGlgu0ENsCPw8rh3Kf8s6PW7qCmBFuxELGMl2io4HguAuPCuSj0ejCx87uj89dB d3fLfiYyG1q86R7ShRtdI8TThKZgdk3kTxN+I9KlCUE92H/P+ylwI6pxlvqKRi1v tJB/oh+fo1LdF77P+ksmvG1/LLuYpu00c9TKpTRd9tZulinYGQ/adLBX0Fi6PLH7 hMWbmkQsX3WlX/k9uDYBdx6wiP7UZeL0/EPGP/Sb1TWmQxuItocfNJyxB2+67TvS FqFkUpEazYze/AB8QzfADwuZkfAaRKWYtTF44CL0ak4vyEz4CKMXlAp/pdGFLqyQ Wy1pPtxNLPikaTZ6o+DyOo0+6z9c3k/fkWJrrJe+jaLTz2M/yr7mEtnrVLNWVCs9 nvyWLaxeYbW8W1wse1dd34meQ1wPLLPDnA+pfejNLZxmyfuszHRTtm71ckyg8DI9 2IxSUTHfoYsSqCPfQeoEGo7CfVf4IIA8cxGQvm3Mb6/tjx7LvBXd8B07BXrZiomE hbAan1syMEAUC2JHU0CGixtIYDJYc5u2oufNj+/xOcFm 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 0xffff888101d228c0 (size 8): comm "modprobe", pid 276, jiffies 4294722700 (age 13.151s) hex dump (first 8 bytes): 65 72 6f 66 73 00 ff ff erofs... backtrace: [<00000000e2a9a4a6>] __kmalloc_node_track_caller+0x44/0x1b0 [<00000000b8ce02de>] kstrdup+0x3a/0x70 [<000000004a0e01d2>] kstrdup_const+0x63/0x80 [<00000000051b6cda>] kvasprintf_const+0x149/0x180 [<000000004dc51dad>] kobject_set_name_vargs+0x56/0x150 [<00000000b30f0bad>] kobject_set_name+0xab/0xe0 Fixes: 168e9a76200c ("erofs: add sysfs interface") Signed-off-by: Yang Yingliang --- fs/erofs/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index 783bb7b21b51..653b35001bc5 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -254,8 +254,10 @@ int __init erofs_init_sysfs(void) kobject_set_name(&erofs_root.kobj, "erofs"); erofs_root.kobj.parent = fs_kobj; ret = kset_register(&erofs_root); - if (ret) + if (ret) { + kset_put(&erofs_root); goto root_err; + } ret = kobject_init_and_add(&erofs_feat, &erofs_feat_ktype, NULL, "features"); From patchwork Fri Oct 21 02:21:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014210 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 aib29ajc247.phx1.oracleemaildelivery.com (aib29ajc247.phx1.oracleemaildelivery.com [192.29.103.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 321C2C433FE for ; Fri, 21 Oct 2022 02:23:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=XsV3dCli54Rly92a8cFogLV/eF4nO/tsMaNeqYXLjOs=; b=MPHJ5YMr/R6hTcqMz0Ypm6LzS05WKSy0HaoIVvdHk+oOiSA0ZRDNlFciOul7q+4HSnr7Xse3au9f bH6Ijwi5Ll6HeqycSZBxL841OvsaiAnUVLHAoGx1QzSfUxma6zIDAeWKzYp36qgTSQfP3Z6RLw7w OBNi/gHWwX4Y9KtEQIYegSgb/dy/IwxvBXSV+8ed4ydAkbHBYQ2nPtln6Y5KACZvP4yNBWqpRE1+ 9mxBNBTAI8ronC5yB7EFiJMky5fNq3e4A2KdHyClarrbmJdgJIAfFfrjtqvIsrIN28GxWaJPMWFp sPiMS6FXnV/argyNb2EEG/VHIekNmVRtqDmtJA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=XsV3dCli54Rly92a8cFogLV/eF4nO/tsMaNeqYXLjOs=; b=rz6PKX/HhQTW7rC3zyIqkiG+vOD7lYKMHod6Df3djGX/eQQuHSHlD3LtOWX5DHLGxN7c22tOFRyC ULmz1L6YYedpdsKkVUbJyJcOSk4F08uHO8I6QAeSy8tjCwuiznkzLNvveAj6LF/72X04UhlPtGjE qczv4JV9Rug8Z0l0gOjycSY8xB8SrW8JQRR1hBjXa7qqrU8phMj+uOcBp24CtQ7g+kPAXP24+qBC FmREJ8GoxOkUNNfwt9Txh0+XI0Zr/vLYcPJNll6eOsbX+hcsFb6/jcJ/IWF6G5WgG40O2+XNcw3j 1TcI4GozVNIABRNrpEC+T23JOCM5AsWr3/wsaw== Received: by omta-ad1-fd3-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK200HQRZZ5I150@omta-ad1-fd3-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:29 +0000 (GMT) To: , , , , , , 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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 clxscore=-57 suspectscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 09/11] ocfs2: possible memory leak in mlog_sys_init() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: 3Z4TGLUbYuCMskNs4tIYmv2qQ4LWT_7l X-Proofpoint-GUID: 3Z4TGLUbYuCMskNs4tIYmv2qQ4LWT_7l Reporting-Meta: AAGRfGcH+HM0znrHhE+MqXw+8rwTsEduEoCGfMVT0xNITIm7ixlJ+aKkrqMYLBnI kaMareD/2PIJAVUIW9YcOQ2336aEbj+9oHC1XfMWWfCytzFgYWCn00wv8kgOdQ7T Dv5pZuNhUrE/v0P5uqGXSJ8ScWS/8lcQTt1NSd4qMeRsdjGYECtq/O+wAaJf2HlG QUsX66C5/PWPu3kng9LvFP0dSrPS7W4My9pPdcrEJH3/zofd+uKvz3YsELZPFIjm O4O5C5QX/MTrRzTB0m1aiCGfDku6vwG7bAm6ekU/YQRP1N+Ha6OMXAUnP93dS68v 8G6WnEmtS/476q6Pq5EiE90Sgdvmq0UlQNq/UE/nY/GcM2xCPZHGw/N8KxESLd4Q SWi9f7SrlxjvFkpiUBMd3i1n7pu1CFzFnghJZ7iX0iqDosQ/BzaLE7wOgz2nd1JP Q0d5Rc3xOnQbqxnz07HEeUeisk25kYSanwYIt6fBDAGkmkfJRuv1/YL9TikwL/9S Vf0p/MaJR1AdHgbRe92wfpO9INX6bgu8fmq+bqOdRb0H 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 kset") 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 = { int mlog_sys_init(struct kset *o2cb_kset) { int i = 0; + int ret; while (mlog_attrs[i].attr.mode) { mlog_default_attrs[i] = &mlog_attrs[i].attr; @@ -165,7 +166,11 @@ int mlog_sys_init(struct kset *o2cb_kset) kobject_set_name(&mlog_kset.kobj, "logmask"); mlog_kset.kobj.kset = o2cb_kset; - return kset_register(&mlog_kset); + ret = kset_register(&mlog_kset); + if (ret) + kset_put(&mlog_kset); + + return ret; } void mlog_sys_shutdown(void) From patchwork Fri Oct 21 02:21:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014205 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 aib29ajc254.phx1.oracleemaildelivery.com (aib29ajc254.phx1.oracleemaildelivery.com [192.29.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B08C5C4332F for ; Fri, 21 Oct 2022 02:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=N5YBqJY4eTH5kqGNyOxsZt2QOM3We9V1np9MR4UDO9o=; b=JXCu/lDz9AyeBKUCcU5oFpDqsYJ0nU3qPvSEd5bbwS3YDoxXx++JuMZIJR3+0XaSKR95Xh3L++Mx o+Nhfmrc3Z+j+sRA1fKmrerIfQfE+6y+NkT3hNmIQ7bQ9Hfsdi7sU/BHvKVNz5ywzVenXxB1rV+y xJ497Xe15Ho2AbPEqPm06oYtsIG33TrXwcxefBwkVAPK4BwaLiuu2opMrh4vIZKeuIwlZQyZFJmJ ELK5tNJQ0S7I03sNKIge66KY8vxnsuNw5RZkSR2sSxbieCgXXEmnRtlB3gETFXZRkBlyu7ZxMzs0 BrIc3jxQ96lAhDlYsXNMNdTE0PgwWGfKH3TGkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=N5YBqJY4eTH5kqGNyOxsZt2QOM3We9V1np9MR4UDO9o=; b=eztg/4AnIcQmDNFaGzhs3tgxYHXEzYspLZLto7skWGxtbkk+mYe/c77vWvaMxIghaSS2mjLVhIR5 NnkMFBTAEAnGxHYHpzMU27N8L1JIOCRUIArH6LfmS5Jwy1RoDohl/wKuTna8BEJ71ICStfbG4R4e jD5GvVbZqYBdQdOHQXEEIK06Scp8NO5cbVbyxJjzE3b/5btuxV0tuRKzOHuY7sjKC2Szpj0ibp9F zXHSLAuROf8W93bBrgkImCCQs2+wxRs/7W5Fk3FazmYtH+GCEDvur6NrEHR+mo/xFdaCMSn18qFl iO/gfYQIrHa5sHZC7OnQbdQt19jRingXOrUc9g== Received: by omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK20093IZYC5GA0@omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:00 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:21:01 +0800 Message-id: <20221021022102.2231464-11-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.188 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 lowpriorityscore=0 clxscore=28 priorityscore=212 mlxlogscore=999 spamscore=0 phishscore=0 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 10/11] drm/amdgpu/discovery: fix possible memory leak X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga02-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-ORIG-GUID: v0B_pgSsos_saQ-EQLZnPiFdw8tPCOCK X-Proofpoint-GUID: v0B_pgSsos_saQ-EQLZnPiFdw8tPCOCK Reporting-Meta: AAFMtwi5BHwwFqKq1tzSl3eDb3AYsPdhq2olwWkLrNVo510saKNNJuGq+LMYGR6s 7ghht1iA6y9WGCFSygJhblFJBOCnFMSS0WuFD+2yt+dZoig6kXER86yvTUINI3Uz VMmj2ixLl6HavxD2MGZ5Kk5LOQzqOcVt4LXYd74cUXoYRdTvmZtyl+SwKg8gOC8v fnmPw0xtIj6LBdytYNiOLpS34y87iQKaVHYaC+6jVj9Hb2aaBpnWW8f6qZd7pSyI hwDbslGPYE+EBOo1cCM9Kz9QvAD9cUk0Df7ChY8G9HHCo4kLgZfJM8IgNqK1DMrX TNO+mxbfyV5yikJ3k/cP7yM2cqUjyaoavYgk4wtcm5pIAOvaB7sF9og3EgXRFhno jQdq3i/AZm/9SmzrNZfHOMTm4HUkLHnW1qrdKZIjxdls661Nk7Rx8MY61vMjoCOZ j4ZMM3fH/YV9/ucYph3KUzm8EZx5Jy9YRlP4pRoFH/r0p4qeHemZt/TwJSionAyr XPgV5GwaxkCADardCOdJcMxpJmhWvJmE0+PC1fJPiNkrHw== If kset_register() fails, the refcount of kobject is not 0, the name allocated in kobject_set_name(&kset.kobj, ...) is leaked. Fix this by calling kset_put(), so that it will be freed in callback function kobject_cleanup(). Cc: stable@vger.kernel.org Fixes: a6c40b178092 ("drm/amdgpu: Show IP discovery in sysfs") Signed-off-by: Yang Yingliang Reviewed-by: Luben Tuikov --- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c index 3993e6134914..638edcf70227 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c @@ -863,7 +863,7 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, res = kset_register(&ip_hw_id->hw_id_kset); if (res) { DRM_ERROR("Couldn't register ip_hw_id kset"); - kfree(ip_hw_id); + kset_put(&ip_hw_id->hw_id_kset); return res; } if (hw_id_names[ii]) { @@ -954,7 +954,7 @@ static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev) res = kset_register(&ip_die_entry->ip_kset); if (res) { DRM_ERROR("Couldn't register ip_die_entry kset"); - kfree(ip_die_entry); + kset_put(&ip_die_entry->ip_kset); return res; } @@ -989,6 +989,7 @@ static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev) res = kset_register(&adev->ip_top->die_kset); if (res) { DRM_ERROR("Couldn't register die_kset"); + kset_put(&adev->ip_top->die_kset); goto Err; } From patchwork Fri Oct 21 02:21:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 13014206 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 aib29ajc245.phx1.oracleemaildelivery.com (aib29ajc245.phx1.oracleemaildelivery.com [192.29.103.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F068AC43217 for ; Fri, 21 Oct 2022 02:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=VgxvJJ/Jc/8LRosGrmnbU5IknoS709MuKY91QHE/k9k=; b=sOFl8XWBq/nHLCr0AcJq5RIYkqfsWwS0RJoQF9s7DGOsk7cW3rO92oXwwhkdDFjSDE/XmsB3op0R LI120v6GlUypz+6cTBSOTyHrrqNjJs9h17mOndhfJYuHsME2I/okR+aTICc+It1ctvkJo20KVnwa TN+pjjb9kFf6buBIyLLu/vc/WGJ0TpVPBLZbwWLmnx3VYXZrv68tbqiJFGIqTPXoYBBbhCL5kyFS bOIpyPFxdAnkQe1+QFio6xb2JjuV4eSawyMMor2ReS0ycK/hjGgjgo73mJNsGQxivWQP+T5fY+GD Twy5o2PwviK4ah+VCmIk0EZF6r3dDbcCR2Uelg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=VgxvJJ/Jc/8LRosGrmnbU5IknoS709MuKY91QHE/k9k=; b=hVphgLcgwH/RWe+gnbAen2i2zf424FIZg9a70Br/Wub+Ds+oQ3rwif9LnWSiqIdw2SWASk0Pjg9g 6PXt9Cj126Z9NfChenkDsKY98Lj1CjsmrKPlSBswHbfQwy5yS5/1XrkphOZZxcevF/e55wPwxZo9 L+xjKHcS2xgHvXvU2b4NzdMCKOydWrHtmeBbhTJTbxSB/KkwwC2CrmxneGjTIr7fuIlOu67ZQSPk b26TPhd0ZClZX7SaJOfBev1rQEfioKoOFqIEYsYnJAV+8mvqlz90Wa8Bn9HnU4GICy5keAs19GPW yCJSjI/PUNY33p6MmynpTowFsHCZoHllh0Ovow== Received: by omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RK200KGZZYC7QB0@omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 21 Oct 2022 02:23:00 +0000 (GMT) To: , , , , , , Date: Fri, 21 Oct 2022 10:21:02 +0800 Message-id: <20221021022102.2231464-12-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 X-Originating-IP: [10.175.103.91] X-Source-IP: 45.249.212.187 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10506 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=223 impostorscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=979 adultscore=0 bulkscore=0 clxscore=25 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210210011 domainage_hfrom=8319 Cc: alexander.deucher@amd.com, richard@nod.at, mst@redhat.com, gregkh@linuxfoundation.org, somlo@cmu.edu, chao@kernel.org, huangjianan@oppo.com, liushixin2@huawei.com, luben.tuikov@amd.com, hsiangkao@linux.alibaba.com, rafael@kernel.org, jaegeuk@kernel.org Subject: [Ocfs2-devel] [PATCH 11/11] ubifs: Fix memory leak in ubifs_sysfs_init() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Yang Yingliang via Ocfs2-devel Reply-to: Yang Yingliang Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-ServerName: szxga01-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:168.195.93.47 ip4:185.176.79.56 ip4:119.8.179.247 ip4:119.8.89.136/31 ip4:119.8.89.135 ip4:119.8.177.36/31 ip4:119.8.177.38 -all X-Spam: Clean X-Proofpoint-GUID: oD8InqKsFYgJ2P42ZV9i3pxeIYd_XcbN X-Proofpoint-ORIG-GUID: oD8InqKsFYgJ2P42ZV9i3pxeIYd_XcbN Reporting-Meta: AAEEFqEROhsUH2JFQKSN1lyoWoc1mjN1+JrayHs6vPvFtQW3VIjDfy2nG29Q43FZ ApE/1d6sPbFFX12sEpmBK7ES8rdPgFrdMWG2n1JXF/Bxakr/NKdcbx6O2Dc4jnah BPpjOHhoLUL0YviwHrNEKsf+HmhqGqzp9qIid/YCRQHS893H87WQ0YKCT4RqkCpo 4zCzyusmYZEY13hNykwjPpRdAw/2QM5R7c2b51xNkOsNhafzzwVXwx1UE7eJGmQU dDqRQLqtB56Z566c69L/9qxCWtPfBzSKRiOOCueH4FGOpQ0UYkp7lyymOk+wfgFS AcNOxjnNgEKYboEmOi39vhHchmOzDpDtV3J/uEGbLeVEQ/kqjna2YuvxVkE4rAUR Bw1NgnyV5IjouFJc0Hju+NBrSXSGUD8IcTf+bDcn9COWy5M6DsPpfc//r/Byx9gJ fPKLAy978Cxht+KuJIaohVM9UQrU3DYC1oBcoeiER9216docbsJLqi0yrGeH2a/P HmZDXLOdq73OZAIYtV78FRTEFwldV1M2GQAFrKE9AMJbCg== From: Liu Shixin When insmod ubifs.ko, a kmemleak reported as below: unreferenced object 0xffff88817fb1a780 (size 8): comm "insmod", pid 25265, jiffies 4295239702 (age 100.130s) hex dump (first 8 bytes): 75 62 69 66 73 00 ff ff ubifs... backtrace: [] slab_post_alloc_hook+0x9c/0x3c0 [] __kmalloc_track_caller+0x183/0x410 [] kstrdup+0x3a/0x80 [] kstrdup_const+0x66/0x80 [] kvasprintf_const+0x155/0x190 [] kobject_set_name_vargs+0x5b/0x150 [] kobject_set_name+0xbb/0xf0 [] do_one_initcall+0x14c/0x5a0 [] do_init_module+0x1f0/0x660 [] load_module+0x6d7e/0x7590 [] __do_sys_finit_module+0x19f/0x230 [] __x64_sys_finit_module+0x73/0xb0 [] do_syscall_64+0x35/0x80 [] entry_SYSCALL_64_after_hwframe+0x63/0xcd When kset_register() failed, we should call kset_put to cleanup it. Fixes: 2e3cbf425804 ("ubifs: Export filesystem error counters") Signed-off-by: Liu Shixin Signed-off-by: Yang Yingliang --- fs/ubifs/sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ubifs/sysfs.c b/fs/ubifs/sysfs.c index 06ad8fa1fcfb..54270ad36321 100644 --- a/fs/ubifs/sysfs.c +++ b/fs/ubifs/sysfs.c @@ -144,6 +144,8 @@ int __init ubifs_sysfs_init(void) kobject_set_name(&ubifs_kset.kobj, "ubifs"); ubifs_kset.kobj.parent = fs_kobj; ret = kset_register(&ubifs_kset); + if (ret) + kset_put(&ubifs_kset); return ret; }