Message ID | 20190122152151.16139-5-gregkh@linuxfoundation.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: aoe: no need to check return value of debugfs_create functions | expand |
On Tue, Jan 22, 2019 at 04:21:04PM +0100, 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: "Ed L. Cashin" <ed.cashin@acm.org> > Cc: Jens Axboe <axboe@kernel.dk> > Cc: linux-block@vger.kernel.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > drivers/block/aoe/aoeblk.c | 13 +------------ > 1 file changed, 1 insertion(+), 12 deletions(-) > > diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c > index e2c6aae2d636..b602646bfa04 100644 > --- a/drivers/block/aoe/aoeblk.c > +++ b/drivers/block/aoe/aoeblk.c > @@ -207,14 +207,7 @@ aoedisk_add_debugfs(struct aoedev *d) > else > p++; > BUG_ON(*p == '\0'); > - entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d, > - &aoe_debugfs_fops); > - if (IS_ERR_OR_NULL(entry)) { > - pr_info("aoe: cannot create debugfs file for %s\n", > - d->gd->disk_name); > - return; > - } > - BUG_ON(d->debugfs); > + debugfs_create_file(p, 0444, aoe_debugfs_dir, d, &aoe_debugfs_fops); > d->debugfs = entry; Now entry is uninitialized here when we assign it to d->debugfs. > } > void > @@ -472,10 +465,6 @@ aoeblk_init(void) > if (buf_pool_cache == NULL) > return -ENOMEM; > aoe_debugfs_dir = debugfs_create_dir("aoe", NULL); > - if (IS_ERR_OR_NULL(aoe_debugfs_dir)) { > - pr_info("aoe: cannot create debugfs directory\n"); > - aoe_debugfs_dir = NULL; > - } > return 0; > } > > -- > 2.20.1 >
On Tue, Jan 22, 2019 at 6:29 PM Omar Sandoval <osandov@osandov.com> wrote:
...
> Now entry is uninitialized here when we assign it to d->debugfs.
Thanks for noticing that.
On Tue, Jan 22, 2019 at 03:29:33PM -0800, Omar Sandoval wrote: > On Tue, Jan 22, 2019 at 04:21:04PM +0100, 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: "Ed L. Cashin" <ed.cashin@acm.org> > > Cc: Jens Axboe <axboe@kernel.dk> > > Cc: linux-block@vger.kernel.org > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > --- > > drivers/block/aoe/aoeblk.c | 13 +------------ > > 1 file changed, 1 insertion(+), 12 deletions(-) > > > > diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c > > index e2c6aae2d636..b602646bfa04 100644 > > --- a/drivers/block/aoe/aoeblk.c > > +++ b/drivers/block/aoe/aoeblk.c > > @@ -207,14 +207,7 @@ aoedisk_add_debugfs(struct aoedev *d) > > else > > p++; > > BUG_ON(*p == '\0'); > > - entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d, > > - &aoe_debugfs_fops); > > - if (IS_ERR_OR_NULL(entry)) { > > - pr_info("aoe: cannot create debugfs file for %s\n", > > - d->gd->disk_name); > > - return; > > - } > > - BUG_ON(d->debugfs); > > + debugfs_create_file(p, 0444, aoe_debugfs_dir, d, &aoe_debugfs_fops); > > d->debugfs = entry; > > Now entry is uninitialized here when we assign it to d->debugfs. Ah, good catch, I'll go fix this up and post a v2, sorry about that. greg k-h
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index e2c6aae2d636..b602646bfa04 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c @@ -207,14 +207,7 @@ aoedisk_add_debugfs(struct aoedev *d) else p++; BUG_ON(*p == '\0'); - entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d, - &aoe_debugfs_fops); - if (IS_ERR_OR_NULL(entry)) { - pr_info("aoe: cannot create debugfs file for %s\n", - d->gd->disk_name); - return; - } - BUG_ON(d->debugfs); + debugfs_create_file(p, 0444, aoe_debugfs_dir, d, &aoe_debugfs_fops); d->debugfs = entry; } void @@ -472,10 +465,6 @@ aoeblk_init(void) if (buf_pool_cache == NULL) return -ENOMEM; aoe_debugfs_dir = debugfs_create_dir("aoe", NULL); - if (IS_ERR_OR_NULL(aoe_debugfs_dir)) { - pr_info("aoe: cannot create debugfs directory\n"); - aoe_debugfs_dir = NULL; - } return 0; }
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: "Ed L. Cashin" <ed.cashin@acm.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: linux-block@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/block/aoe/aoeblk.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)