RE: [PATCH] watchdog: mei_wdt: no need to check return value of debugfs_create functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> 
> > ---
> >  drivers/watchdog/mei_wdt.c | 30 +++++++-----------------------
> >  1 file changed, 7 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/watchdog/mei_wdt.c b/drivers/watchdog/mei_wdt.c
> > index 8023cf28657a..96a770938ff0 100644
> > --- a/drivers/watchdog/mei_wdt.c
> > +++ b/drivers/watchdog/mei_wdt.c
> > @@ -539,38 +539,23 @@ static void dbgfs_unregister(struct mei_wdt *wdt)
> >  	wdt->dbgfs_dir = NULL;
> >  }
> >
> > -static int dbgfs_register(struct mei_wdt *wdt)
> > +static void dbgfs_register(struct mei_wdt *wdt)
> >  {
> > -	struct dentry *dir, *f;
> > +	struct dentry *dir;
> >
> >  	dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
> > -	if (!dir)
> > -		return -ENOMEM;
If create dir fails but  the consequent create file succeeds,  I would guess this will be a mess in the debugs root directory. 
Also the tear down won't work as debugfs_remove_recursive will just bail out on NULL check.
Isn't it better just return here, when create_dir fails? 

> > -
> >  	wdt->dbgfs_dir = dir;
> > -	f = debugfs_create_file("state", S_IRUSR, dir, wdt, &dbgfs_fops_state);
> > -	if (!f)
> > -		goto err;
> >
> > -	f = debugfs_create_file("activation",  S_IRUSR,
> > -				dir, wdt, &dbgfs_fops_activation);
> > -	if (!f)
> > -		goto err;
> > +	debugfs_create_file("state", S_IRUSR, dir, wdt, &dbgfs_fops_state);
> >
> > -	return 0;
> > -err:
> > -	dbgfs_unregister(wdt);
> > -	return -ENODEV;
> > +	debugfs_create_file("activation", S_IRUSR, dir, wdt,
> > +			    &dbgfs_fops_activation);
> >  }
> >
> >  #else
> >
> >  static inline void dbgfs_unregister(struct mei_wdt *wdt) {}
> > -
> > -static inline int dbgfs_register(struct mei_wdt *wdt) -{
> > -	return 0;
> > -}
> > +static inline void dbgfs_register(struct mei_wdt *wdt) {}
> >  #endif /* CONFIG_DEBUG_FS */
> >
> >  static int mei_wdt_probe(struct mei_cl_device *cldev, @@ -623,8
> > +608,7 @@ static int mei_wdt_probe(struct mei_cl_device *cldev,
> >  	if (ret)
> >  		goto err_disable;
> >
> > -	if (dbgfs_register(wdt))
> > -		dev_warn(&cldev->dev, "cannot register debugfs\n");
> > +	dbgfs_register(wdt);
> >
> >  	return 0;
> >
> > --
> > 2.22.0
> >



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux