* [patch] usb: gadget: gr_udc: debugfs functions return NULL on error
@ 2014-01-09 5:39 Dan Carpenter
2014-01-09 6:01 ` Greg Kroah-Hartman
2014-01-09 6:06 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2014-01-09 5:39 UTC (permalink / raw)
To: kernel-janitors
Debugfs functions return NULL on error. They return an ERR_PTR if you
don't have debugfs configured.
The way it's designed is that normally you are only supposed to test for
NULL. In this code, if "dev->dfs_root" is an ERR_PTR then passing it to
debugfs_create_file() will not cause a problem because
debugfs_create_file() would also just a stub.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
index 5f9c65959dd2..b34a52171568 100644
--- a/drivers/usb/gadget/gr_udc.c
+++ b/drivers/usb/gadget/gr_udc.c
@@ -226,13 +226,13 @@ static void gr_dfs_create(struct gr_udc *dev)
const char *name = "gr_udc_state";
dev->dfs_root = debugfs_create_dir(dev_name(dev->dev), NULL);
- if (IS_ERR(dev->dfs_root)) {
+ if (!dev->dfs_root) {
dev_err(dev->dev, "Failed to create debugfs directory\n");
return;
}
dev->dfs_state = debugfs_create_file(name, 0444, dev->dfs_root,
dev, &gr_dfs_fops);
- if (IS_ERR(dev->dfs_state))
+ if (!dev->dfs_state)
dev_err(dev->dev, "Failed to create debugfs file %s\n", name);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] usb: gadget: gr_udc: debugfs functions return NULL on error
2014-01-09 5:39 [patch] usb: gadget: gr_udc: debugfs functions return NULL on error Dan Carpenter
@ 2014-01-09 6:01 ` Greg Kroah-Hartman
2014-01-09 6:06 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2014-01-09 6:01 UTC (permalink / raw)
To: kernel-janitors
On Thu, Jan 09, 2014 at 08:39:37AM +0300, Dan Carpenter wrote:
> Debugfs functions return NULL on error. They return an ERR_PTR if you
> don't have debugfs configured.
>
> The way it's designed is that normally you are only supposed to test for
> NULL. In this code, if "dev->dfs_root" is an ERR_PTR then passing it to
> debugfs_create_file() will not cause a problem because
> debugfs_create_file() would also just a stub.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
> index 5f9c65959dd2..b34a52171568 100644
> --- a/drivers/usb/gadget/gr_udc.c
> +++ b/drivers/usb/gadget/gr_udc.c
> @@ -226,13 +226,13 @@ static void gr_dfs_create(struct gr_udc *dev)
> const char *name = "gr_udc_state";
>
> dev->dfs_root = debugfs_create_dir(dev_name(dev->dev), NULL);
> - if (IS_ERR(dev->dfs_root)) {
> + if (!dev->dfs_root) {
> dev_err(dev->dev, "Failed to create debugfs directory\n");
> return;
> }
> dev->dfs_state = debugfs_create_file(name, 0444, dev->dfs_root,
> dev, &gr_dfs_fops);
> - if (IS_ERR(dev->dfs_state))
> + if (!dev->dfs_state)
> dev_err(dev->dev, "Failed to create debugfs file %s\n", name);
> }
Don't even check the return value of the calls, I don't think it
matters, right?
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] usb: gadget: gr_udc: debugfs functions return NULL on error
2014-01-09 5:39 [patch] usb: gadget: gr_udc: debugfs functions return NULL on error Dan Carpenter
2014-01-09 6:01 ` Greg Kroah-Hartman
@ 2014-01-09 6:06 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2014-01-09 6:06 UTC (permalink / raw)
To: kernel-janitors
On Wed, Jan 08, 2014 at 10:01:21PM -0800, Greg Kroah-Hartman wrote:
> On Thu, Jan 09, 2014 at 08:39:37AM +0300, Dan Carpenter wrote:
> > Debugfs functions return NULL on error. They return an ERR_PTR if you
> > don't have debugfs configured.
> >
> > The way it's designed is that normally you are only supposed to test for
> > NULL. In this code, if "dev->dfs_root" is an ERR_PTR then passing it to
> > debugfs_create_file() will not cause a problem because
> > debugfs_create_file() would also just a stub.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c
> > index 5f9c65959dd2..b34a52171568 100644
> > --- a/drivers/usb/gadget/gr_udc.c
> > +++ b/drivers/usb/gadget/gr_udc.c
> > @@ -226,13 +226,13 @@ static void gr_dfs_create(struct gr_udc *dev)
> > const char *name = "gr_udc_state";
> >
> > dev->dfs_root = debugfs_create_dir(dev_name(dev->dev), NULL);
> > - if (IS_ERR(dev->dfs_root)) {
> > + if (!dev->dfs_root) {
> > dev_err(dev->dev, "Failed to create debugfs directory\n");
> > return;
> > }
> > dev->dfs_state = debugfs_create_file(name, 0444, dev->dfs_root,
> > dev, &gr_dfs_fops);
> > - if (IS_ERR(dev->dfs_state))
> > + if (!dev->dfs_state)
> > dev_err(dev->dev, "Failed to create debugfs file %s\n", name);
> > }
>
> Don't even check the return value of the calls, I don't think it
> matters, right?
>
I assume your question is rhetorical since you wrote debugfs... :P
Yes, I looked and if we don't create the initial directory then the
files get put in parent directory instead.
I'll resend this.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-09 6:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-09 5:39 [patch] usb: gadget: gr_udc: debugfs functions return NULL on error Dan Carpenter
2014-01-09 6:01 ` Greg Kroah-Hartman
2014-01-09 6:06 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox