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: Tue, 19 Dec 2017 16:30:14 -0800 Message-ID: <20171219163014.1434bb62@cakuba.netronome.com> References: <002201d3723b$0e2b9310$2a82b930$@lab.ntt.co.jp> <20171211104029.63635671@cakuba.netronome.com> <014801d37884$3cc5d290$b65177b0$@lab.ntt.co.jp> <20171219.091152.920867492172236638.davem@davemloft.net> <024601d37927$b7e83410$27b89c30$@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-f181.google.com ([209.85.216.181]:40350 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753921AbdLTAaU (ORCPT ); Tue, 19 Dec 2017 19:30:20 -0500 Received: by mail-qt0-f181.google.com with SMTP id u42so26424676qte.7 for ; Tue, 19 Dec 2017 16:30:19 -0800 (PST) In-Reply-To: <024601d37927$b7e83410$27b89c30$@lab.ntt.co.jp> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 20 Dec 2017 09:16:01 +0900, Prashant Bhole wrote: > > From: David Miller [mailto:davem@davemloft.net] > > > > From: "Prashant Bhole" > > Date: Tue, 19 Dec 2017 13:45:47 +0900 > > > > > I tried to evaluate whether fixing return value of > > > debugfs_create_dir() (and > > > friends) will be useful or not because it has not been changed since > > > very long time. Now I am not much convinced about changing this api. > > > > > > Important and possible error codes could be -EEXIST and -ENOMEM. > > > Suppose -EEXIST is returned, IMO the directory shouldn't exists in the > > > first place because it is specific to particular module. Also, there > > > is no point in creating file in such directory, because directory > > > owner (creator) might remove it too. This means there are less chances > > > that api change will be useful. Please let me know your opinion on it. > > > > > > If you are ok with above explanation, shall I submit v2 for this patch? > > > > Well, something is seriously wrong if the directory exists already. > > > > It could be that two netdevsim modules, independantly compiled, are trying > to > > be loaded. > > > > Wouldn't it clearly be desirable to fail and not load the module in that > case? > > > > This is why I think ignoring debugfs errors is foolish. > > Right. I am planning to do following (quoting previous mail), In debugfs > error will not be ignored in modules load. > ----------- > 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; Ack. > 2) In case sim0 or bpf_bound_progs are fail to create, we need to add > checks before creating any file in them. What do you mean by "check before"? Checking if creation of each file fails or not, or something different?