From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH net-next] netdevsim: correctly check return value of debugfs_create_dir Date: Mon, 11 Dec 2017 10:40:29 -0800 Message-ID: <20171211104029.63635671@cakuba.netronome.com> References: <20171208005250.2972-1-bhole_prashant_q7@lab.ntt.co.jp> <20171208.103110.1740849637875852344.davem@davemloft.net> <002201d3723b$0e2b9310$2a82b930$@lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "'David Miller'" , To: "Prashant Bhole" Return-path: Received: from mail-qt0-f195.google.com ([209.85.216.195]:43063 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbdLKSkd (ORCPT ); Mon, 11 Dec 2017 13:40:33 -0500 Received: by mail-qt0-f195.google.com with SMTP id w10so41061355qtb.10 for ; Mon, 11 Dec 2017 10:40:32 -0800 (PST) In-Reply-To: <002201d3723b$0e2b9310$2a82b930$@lab.ntt.co.jp> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 11 Dec 2017 13:46:48 +0900, Prashant Bhole wrote: > > From: David Miller [mailto:davem@davemloft.net] > > > > From: Prashant Bhole > > Date: Fri, 8 Dec 2017 09:52:50 +0900 > > > > > Return value is now checked with IS_ERROR_OR_NULL because > > > debugfs_create_dir doesn't return error value. It either returns NULL > > > or a valid pointer. > > > > > > Signed-off-by: Prashant Bhole > > > --- > > > drivers/net/netdevsim/netdev.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/netdevsim/netdev.c > > > b/drivers/net/netdevsim/netdev.c index eb8c679fca9f..88d8ee2c89da > > > 100644 > > > --- a/drivers/net/netdevsim/netdev.c > > > +++ b/drivers/net/netdevsim/netdev.c > > > @@ -469,7 +469,7 @@ static int __init nsim_module_init(void) > > > int err; > > > > > > nsim_ddir = debugfs_create_dir(DRV_NAME, NULL); > > > - if (IS_ERR(nsim_ddir)) > > > + if (IS_ERR_OR_NULL(nsim_ddir)) > > > return PTR_ERR(nsim_ddir); > > > > debugfs_create_dir() should really be fixed, either it uses error pointers > > consistently and therefore always provides a suitable error code to return > or it > > always uses NULL. > > > > This in-between behavior makes using it as an interface painful because no > clear > > meaning is given to NULL. > > > > So please do the work necessary to make debugfs_create_dir()'s return > > semantics clearer and more useful. > > > > Thank you. > > Dave, > Thanks for comments. I will try to fix error handling in netdevsim first. > > Jakub, > Let's decide with an example. The typical directory structure for netdevsim > interface is as below: > /sys/kernel/debug/netdevsim/sim0/bpf_bound_progs/ > Please let me know if you are ok with following: > > 1) If debugfs_create_dir() fails in module_init, let's keep it fatal error > with corrected condition: > + if (IS_ERR_OR_NULL(nsim_ddir)) > + return -ENOMEM; > > 2) In case sim0 or bpf_bound_progs are fail to create, we need to add > checks before creating any file in them. Fine with me, although if you fix DebugFS first you could use the real error from the start here.