Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7066784ybi; Thu, 13 Jun 2019 09:01:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxA5fKEYQQkKlgAekTjA5QSVF4IYNtwp3PW+YAUQGFo03/9dSNl0UjdQsbjS6zQUoXPJeXl X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr4467722plb.270.1560441706111; Thu, 13 Jun 2019 09:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560441706; cv=none; d=google.com; s=arc-20160816; b=I28jD+BmNhcl9lLrh2Ncp/T7yiiqroUHTG9v1Oa5C7Ys8vk6H6vxnf2vXNU3MxWd8l ZYJ6OYfx0eXwXrI8CY2kltajt5vrh+OazucYR/jX/1utQZfcQ8asYRYUdBCw+3Vjp0kc DlHsWRhDH2l5JqaPu8NKbAWKeZRjCMqERWA2KAs/UcsNuIcrynvFBVSThc6+VnvjXtYP YRKH1RKj8Y+TZxDNKF+bKVOENjJE5Dsw1KUol6qBgNjNrd9irlehd2167giWprnowSfr UIi65yHpVTKsx4dyfGBG1m3TU+kg9b5IqRfok2GWfD4NdBG626jDS5mcHyOn3F39Vh7M sE3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bMegm+mFbHma4Vpthquz4qpnjnfQUAXAftP8o0HV/6s=; b=jJKxHZjILju0fN9jqF2wY15GX2/WUEp6pe8YYoNn7ka0ZGh4MSVXmOh2fKGKvW0Oye /5DBIQCY9SsL4PuHNkFzxECJf5Czk83OE4VcUKxzYsrjv3lqRQXgWeNbeKUb5yyBTM7x yObsjUwfpuGPyQGthPO7B8dMgdzymKQQaQQvm4IT96Xuvq0ZTSh/qMtDoGKVIovQHuB8 BBYdNIKWBx9BIGoR9GMgJPFRYkwwNOQT7QJvJJFyPHSi5IIUjk+CVc1McwuoqgC6nFxD 42nymqgU2aZSOLmis86toW9Hr17WxmVsXYD6MAdOUDFu3nLhEZzukPlUeg0Bn+FDB5/c HeeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ey/FNBRL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si36408pjq.54.2019.06.13.09.01.29; Thu, 13 Jun 2019 09:01:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ey/FNBRL"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390426AbfFMP7L (ORCPT + 99 others); Thu, 13 Jun 2019 11:59:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:52742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731464AbfFMP7K (ORCPT ); Thu, 13 Jun 2019 11:59:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95A0E20679; Thu, 13 Jun 2019 15:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560441549; bh=RRQxcgXUwrlkOVPgdav87tLtU/bhO27ihR80lUwUJfs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ey/FNBRLnuJkhNyrtcLH90wayHk3JFGzz8AGMAyrZDdtJSKcGmEk5yEeEcF6MiSiP ZrNCqdAhnO0/R0+icfLLyvfUwex/fahV/Nve4/pJYsG2JDfYObNCA06N8WlRh47n3+ kOsjcyfYNs1CYndsxJWG7U88K4bP6uCVfoxwveB8= Date: Thu, 13 Jun 2019 17:59:06 +0200 From: Greg Kroah-Hartman To: Jason Baron Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib: dynamic_debug: no need to check return value of debugfs_create functions Message-ID: <20190613155906.GB4632@kroah.com> References: <20190612153534.GA21141@kroah.com> <4936c8d8-9b69-1385-1bbf-9d19ac08d061@akamai.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4936c8d8-9b69-1385-1bbf-9d19ac08d061@akamai.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 13, 2019 at 10:33:23AM -0400, Jason Baron wrote: > On 6/12/19 11:35 AM, Greg Kroah-Hartman wrote: > > When calling debugfs functions, there is no need to ever check the > > return value. The function can work or not, but the code logic should > > never do something different based on this. > > > > Cc: Jason Baron > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Greg Kroah-Hartman > > --- > > lib/dynamic_debug.c | 12 +++--------- > > 1 file changed, 3 insertions(+), 9 deletions(-) > > > > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > > index 8a16c2d498e9..c60409138e13 100644 > > --- a/lib/dynamic_debug.c > > +++ b/lib/dynamic_debug.c > > @@ -993,20 +993,14 @@ static __initdata int ddebug_init_success; > > > > static int __init dynamic_debug_init_debugfs(void) > > { > > - struct dentry *dir, *file; > > + struct dentry *dir; > > > > if (!ddebug_init_success) > > return -ENODEV; > > > > dir = debugfs_create_dir("dynamic_debug", NULL); > > - if (!dir) > > - return -ENOMEM; > > - file = debugfs_create_file("control", 0644, dir, NULL, > > - &ddebug_proc_fops); > > - if (!file) { > > - debugfs_remove(dir); > > - return -ENOMEM; > > - } > > + debugfs_create_file("control", 0644, dir, NULL, &ddebug_proc_fops); > > + > > return 0; > > } > > > > > > Looks like debugfs_create_dir() can return NULL, No it can not. > and in that case if its passed to debugfs_create_file() then the > 'control' file ends up in the root of debugfs? If it could, yes, that is what would happen. > I think its better to just not create the file then have it in the > wrong place so maybe the file creation should be guarded by > if(IS_ERR_OR_NULL(dir)). As debugfs_create_dir() can not return NULL, you don't have to worry about this :) thanks, greg k-h