lkml.org 
[lkml]   [2022]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: unisys: Properly test debugfs_create_dir() return values
On Tue, Mar 22, 2022 at 11:49:28AM +0300, Dan Carpenter wrote:
> On Tue, Mar 22, 2022 at 09:38:58AM +0100, Fabio M. De Francesco wrote:
> > debugfs_create_dir() returns a pointers to a dentry objects. On failures
> > it returns errors. Currently the values returned to visornic_probe()
> > seem to be tested for being equal to NULL in case of failures.
> >
> > Properly test with "if (IS_ERR())" and then assign the correct error
> > value to the "err" variable.
> >
> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> > ---
> > drivers/staging/unisys/visornic/visornic_main.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c
> > index 643432458105..58d03f3d3173 100644
> > --- a/drivers/staging/unisys/visornic/visornic_main.c
> > +++ b/drivers/staging/unisys/visornic/visornic_main.c
> > @@ -1922,11 +1922,11 @@ static int visornic_probe(struct visor_device *dev)
> > /* create debug/sysfs directories */
> > devdata->eth_debugfs_dir = debugfs_create_dir(netdev->name,
> > visornic_debugfs_dir);
> > - if (!devdata->eth_debugfs_dir) {
> > + if (IS_ERR(devdata->eth_debugfs_dir)) {
>
> Normally I would say to just delete the error handling.

In the normal case checking debugfs functions for errors is not
required. The users all have checks built in. The exception is when
the driver dereferences devdata->eth_debugfs_dir itself. So when you
make these kinds of changes do a grep for eth_debugfs_dir to make sure
it's not dereferenced, but normally it is not.

But again, here, delete everything.

regards,
dan carpenter

\
 
 \ /
  Last update: 2022-03-22 09:57    [W:0.077 / U:0.460 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site