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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B06C001B5 for ; Fri, 2 Sep 2022 15:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236693AbiIBPXV (ORCPT ); Fri, 2 Sep 2022 11:23:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236535AbiIBPWx (ORCPT ); Fri, 2 Sep 2022 11:22:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F4E38BA for ; Fri, 2 Sep 2022 07:56:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1394661E34 for ; Fri, 2 Sep 2022 14:56:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDB38C433D7; Fri, 2 Sep 2022 14:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662130568; bh=8HxsyLelsYqwOCxhTJ5jpbUjl0UPkAy78gN1FK3B4KQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SIfrCsnC9TPzpq/x+bzxefF3RTtWsi1KGr682ovbh1PBJBn9g8++/aZpERT2Hewmq poSK1QtcWyTv+MHbfWWtQZnuTeqVdBDlR4m7Bm6CxoPZ0ZLTstOh/bnB1mYSAUrYFI UGcx0TJUS/P9oScrPgZQT/BrI8uvssK25MpOCLp0= Date: Fri, 2 Sep 2022 16:56:05 +0200 From: Greg Kroah-Hartman To: Al Viro Cc: Kuyo Chang , major.chen@samsung.com, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Matthias Brugger , wsd_upstream@mediatek.com, hongfei.tang@samsung.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 1/1] sched/debug: fix dentry leak in update_sched_domain_debugfs Message-ID: References: <20220902031518.1116-1-kuyo.chang@mediatek.com> <5ce45c874d6a05ca69abed3961d413c4a4360e79.camel@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 02, 2022 at 03:49:27PM +0100, Al Viro wrote: > On Fri, Sep 02, 2022 at 11:11:54AM +0200, Greg Kroah-Hartman wrote: > > > +/** > > + * debugfs_lookup_and_remove - lookup a directory or file and recursively remove it > > + * @name: a pointer to a string containing the name of the item to look up. > > + * @parent: a pointer to the parent dentry of the item. > > + * > > + * This is the equlivant of doing something like > > + * debugfs_remove(debugfs_lookup(..)) but with the proper reference counting > > + * handled for the directory being looked up. > > + */ > > +void debugfs_lookup_and_remove(const char *name, struct dentry *parent) > > +{ > > + struct dentry *dentry; > > + > > + dentry = debugfs_lookup(name, parent); > > + if (IS_ERR_OR_NULL(dentry)) > > + return; > > Could somebody explain how could that return ERR_PTR()? If debugfs is not enabled then debugfs_lookup() will return an ERR_PTR(). But, doh, this _IS_ debugfs so you are right, that will never happen. > Incidentally, IS_ERR_OR_NULL is almost always a sign of bad interface - or > that of lazy cargo-culting. Please, don't propagate that garbage... ;-/ Fair enough, I'll fix that up, many thanks for noticing it. greg k-h 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 214ABECAAD5 for ; Fri, 2 Sep 2022 14:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G7ciXqcdbE1Au7qJEllY2OOGoakayuk5VM7TXe2+WtU=; b=WPPcRa/DkeBusn DpIayb7MaKnYD4nxbPcLSq3gg9UBx6NHpr4EGwhhwkLm65WJdrmXl+baENwZakMK+llHWDFnnvBUc jo83FflPFxKF9noO+H6S1ytY3lqsWRmyOkcjqGGGQrZEzvdTq7HbtlhdQ5bPuSVKG8Xbs+x3lpujd sv8c9kggE/kkVdF/6hQAis7c6wLQ5GWigDBE71/cIN/5Yz5otcHvFVtKOinB+IDxZ45juEn8ZOhSl ciQinJeyJlhV8GG1z5IE7y6WX4RKUsKuB4CqIQbqhPrKycTO/ESDgCUySq/8bHRAEC7DThu2ru2wf vG3HFkceDJvMpAD31z0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU85m-005r62-FL; Fri, 02 Sep 2022 14:56:22 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oU85Z-005qz5-Iv; Fri, 02 Sep 2022 14:56:11 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0C7E460A36; Fri, 2 Sep 2022 14:56:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDB38C433D7; Fri, 2 Sep 2022 14:56:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662130568; bh=8HxsyLelsYqwOCxhTJ5jpbUjl0UPkAy78gN1FK3B4KQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SIfrCsnC9TPzpq/x+bzxefF3RTtWsi1KGr682ovbh1PBJBn9g8++/aZpERT2Hewmq poSK1QtcWyTv+MHbfWWtQZnuTeqVdBDlR4m7Bm6CxoPZ0ZLTstOh/bnB1mYSAUrYFI UGcx0TJUS/P9oScrPgZQT/BrI8uvssK25MpOCLp0= Date: Fri, 2 Sep 2022 16:56:05 +0200 From: Greg Kroah-Hartman To: Al Viro Cc: Kuyo Chang , major.chen@samsung.com, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Matthias Brugger , wsd_upstream@mediatek.com, hongfei.tang@samsung.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 1/1] sched/debug: fix dentry leak in update_sched_domain_debugfs Message-ID: References: <20220902031518.1116-1-kuyo.chang@mediatek.com> <5ce45c874d6a05ca69abed3961d413c4a4360e79.camel@mediatek.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220902_075609_705952_F36163D0 X-CRM114-Status: GOOD ( 19.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 02, 2022 at 03:49:27PM +0100, Al Viro wrote: > On Fri, Sep 02, 2022 at 11:11:54AM +0200, Greg Kroah-Hartman wrote: > > > +/** > > + * debugfs_lookup_and_remove - lookup a directory or file and recursively remove it > > + * @name: a pointer to a string containing the name of the item to look up. > > + * @parent: a pointer to the parent dentry of the item. > > + * > > + * This is the equlivant of doing something like > > + * debugfs_remove(debugfs_lookup(..)) but with the proper reference counting > > + * handled for the directory being looked up. > > + */ > > +void debugfs_lookup_and_remove(const char *name, struct dentry *parent) > > +{ > > + struct dentry *dentry; > > + > > + dentry = debugfs_lookup(name, parent); > > + if (IS_ERR_OR_NULL(dentry)) > > + return; > > Could somebody explain how could that return ERR_PTR()? If debugfs is not enabled then debugfs_lookup() will return an ERR_PTR(). But, doh, this _IS_ debugfs so you are right, that will never happen. > Incidentally, IS_ERR_OR_NULL is almost always a sign of bad interface - or > that of lazy cargo-culting. Please, don't propagate that garbage... ;-/ Fair enough, I'll fix that up, many thanks for noticing it. greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel