Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp438580ybx; Mon, 4 Nov 2019 23:27:48 -0800 (PST) X-Google-Smtp-Source: APXvYqx+yVe3zZocj2xo57lJyTPnqCxK4juxg9QHyhX81/w0pFdZYJfnBLSGwWt2w9MuHSQBmjyx X-Received: by 2002:aa7:d397:: with SMTP id x23mr33484766edq.75.1572938868313; Mon, 04 Nov 2019 23:27:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572938868; cv=none; d=google.com; s=arc-20160816; b=Kvlt6SXSriXQF2KyRyNhOU6c9a34gF3CbxmbPENqYSt7IfPVYtTzV0125lfM6tY47r 0W9vJMzX9z8bcAs+H0r8Fl8zXtoWf4fpjdd2Jj00BNdcCw3pK5cIRw2z1QBMgzYAESRo jKUeQzvkOK/nF+Gsm4UkuWDPyfCw/1xXmYN9f6dEZoWDz7YfwXGIZuLQ49Xszo9uGCKh Calcgxct9gjlet+mcr4uSM0P2t7pU0UmHiBLJl3oC3UeJin10lsYSOVXbsQdKBnv2kPo nEuzsS72jEroRpfyCNTzLAVp2wcGNP464KQLJAcW0sKv72Ji1mMsfpqcORf5oBD5+Ssa GSHw== 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=49KuWJ+wCDzsdLxiu2baBmiJ86L+xsRaAwIz7D9bGq4=; b=Fk3bplAhYUysk626N1qws6WzT8Q0EQBLSUBoGvvOivzCFRmZHy9BEX2LPKsIfM7bWH SOVydA5zYDlNtbW0NNOQ4XH2EwwVbvrNAzZlkxOCWwFOyAXV0SiXZyv52jJ9Ao9LvsEJ xR/8Wo9yj2doxnWv+udBm1j+HRC48Tq3RdwddcHyiNNUgAxRgIyWefg1ssVc8NfvmfC+ K5Va7Q/l9S6HW10K0+x6CYcoQ/WBFOfIfxA/4rDW7x8Ehog9q6t/ndhnl5zLhcV1yA9Z W9ZRfqfFHDn1QYSBkgZHE4FDt0gn+mE6pN6FaytdjWTMUZbpP6JHIly2J+BhxXN5HhNJ o/pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=goBtmMCU; 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 e48si9096169ede.207.2019.11.04.23.27.22; Mon, 04 Nov 2019 23:27:48 -0800 (PST) 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=goBtmMCU; 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 S2387667AbfKEHY3 (ORCPT + 99 others); Tue, 5 Nov 2019 02:24:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:39848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387482AbfKEHY3 (ORCPT ); Tue, 5 Nov 2019 02:24:29 -0500 Received: from localhost (host6-102.lan-isdn.imaginet.fr [195.68.6.102]) (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 0F6F2206BA; Tue, 5 Nov 2019 07:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572938668; bh=2/27uEOZoTHe7dXYgpVVeEFZrEjzn3Ai+nbej1SEAfI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=goBtmMCUQDGZB8aEkC5HYAZSiW/upaQt9Xfyj0Vwfj8lhfqRUOPfXd9ydXQl1M5C3 sEhj8/FXasLAy/RRr9hQq97/pOf0xWmAAOIATC/A2PfgYo3+OZbFyCiKkKReT/qPbi e1o32ZCE494aW4pxz9h7zFTwbo2sbFbNGN5u98Zw= Date: Tue, 5 Nov 2019 08:24:25 +0100 From: Greg Kroah-Hartman To: Mark Bloch Cc: Leon Romanovsky , Doug Ledford , Jason Gunthorpe , "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] IB: mlx5: no need to check return value of debugfs_create functions Message-ID: <20191105072425.GD2587462@kroah.com> References: <20191104074141.GA1292396@kroah.com> <50a30aa3-3924-4fd1-f644-2fd2b184ec0e@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50a30aa3-3924-4fd1-f644-2fd2b184ec0e@mellanox.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 05, 2019 at 12:48:16AM +0000, Mark Bloch wrote: > > > On 11/3/19 11:41 PM, 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: Leon Romanovsky > > Cc: Doug Ledford > > Cc: Jason Gunthorpe > > Signed-off-by: Greg Kroah-Hartman > > --- > > drivers/infiniband/hw/mlx5/main.c | 62 +++++++--------------------- > > drivers/infiniband/hw/mlx5/mlx5_ib.h | 9 +--- > > 2 files changed, 16 insertions(+), 55 deletions(-) > > > > Note, I kind of need to take this through my tree now as I broke the > > build due to me changing the use of debugfs_create_atomic_t() in my > > tree and not noticing this being used here. Sorry about that, any > > objections? > > > > And 0-day seems really broken to have missed this for the past months, > > ugh, I need to stop relying on it... > > > > > > diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c > > index 831539419c30..059db0610445 100644 > > --- a/drivers/infiniband/hw/mlx5/main.c > > +++ b/drivers/infiniband/hw/mlx5/main.c > > @@ -5710,11 +5710,10 @@ static int mlx5_ib_rn_get_params(struct ib_device *device, u8 port_num, > > > > static void delay_drop_debugfs_cleanup(struct mlx5_ib_dev *dev) > > { > > - if (!dev->delay_drop.dbg) > > + if (!dev->delay_drop.dir_debugfs) > > Shouldn't this be: > if (IS_ERR(dev->delay_drop.dir_debugfs)) > return; > ? No, really there should not be any check at all as there is no problem taking the result of a debugfs call and feeding it back into another call. There is no need to check these return values at all. So the code should just be dropped, I can do that as a follow-on if you want me to. > > return; > > - debugfs_remove_recursive(dev->delay_drop.dbg->dir_debugfs); > > - kfree(dev->delay_drop.dbg); > > - dev->delay_drop.dbg = NULL; > > + debugfs_remove_recursive(dev->delay_drop.dir_debugfs); > > + dev->delay_drop.dir_debugfs = NULL; > > Thinking about this more, we already do something like this: > if (IS_ERR_OR_NULL(dentry)) > return; > inside debugfs_remove_recursive(), so this entire function can be reduced > to just calling debugfs_remove_recursive(). Very true, I was trying to keep the patch simple :) thanks, greg k-h