lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191105072425.GD2587462@kroah.com>
Date:   Tue, 5 Nov 2019 08:24:25 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Mark Bloch <markb@...lanox.com>
Cc:     Leon Romanovsky <leon@...nel.org>,
        Doug Ledford <dledford@...hat.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] IB: mlx5: no need to check return value of
 debugfs_create functions

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 <leon@...nel.org>
> > Cc: Doug Ledford <dledford@...hat.com>
> > Cc: Jason Gunthorpe <jgg@...pe.ca>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> > ---
> >  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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ