[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <babb0086-2299-4905-89dd-59e30e1f3c36@lunn.ch>
Date: Wed, 21 Aug 2024 14:31:15 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Yang Ruibin <11162571@...o.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
Gregory Clement <gregory.clement@...tlin.com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
opensource.kernel@...o.com
Subject: Re: [PATCH v1] drivers:bus:Fix the NULL vs IS_ERR() bug for
debugfs_create_dir()
On Wed, Aug 21, 2024 at 07:21:30AM -0400, Yang Ruibin wrote:
> The debugfs_create_dir() function returns error pointers.
> It never returns NULL. So use IS_ERR() to check it.
>
> Signed-off-by: Yang Ruibin <11162571@...o.com>
> ---
> drivers/bus/mvebu-mbus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
> index 3c99d72087eb..42621838ba75 100644
> --- a/drivers/bus/mvebu-mbus.c
> +++ b/drivers/bus/mvebu-mbus.c
> @@ -995,13 +995,13 @@ static __init int mvebu_mbus_debugfs_init(void)
> s->debugfs_root = debugfs_create_dir("mvebu-mbus", NULL);
> if(IS_ERR(s->debugfs_root))
> return PTR_ERR(s->debugfs_root);
> +
You are not supposed to check error codes from debugfs, since it is
optional. The code should just keep going, independent of failure or
success.
> s->debugfs_sdram = debugfs_create_file("sdram", S_IRUGO,
> s->debugfs_root, NULL,
> &mvebu_sdram_debug_fops);
> s->debugfs_devs = debugfs_create_file("devices", S_IRUGO,
> s->debugfs_root, NULL,
> &mvebu_devs_debug_fops);
> - }
I'm surprised this code compiles without this close braces!
Andrew
Powered by blists - more mailing lists