linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/7] usb: fsl_udc_core: check return value of create_proc_read_entry()
@ 2010-07-31 17:38 Kulikov Vasiliy
  2010-07-31 19:17 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Kulikov Vasiliy @ 2010-07-31 17:38 UTC (permalink / raw)
  To: kernel-janitors
  Cc: David Brownell, Greg Kroah-Hartman, linux-kernel, linuxppc-dev,
	linux-usb, Anton Vorontsov, Dinh Nguyen

create_proc_read_entry() may fail, if so return -ENOMEM.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 drivers/usb/gadget/fsl_udc_core.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 08a9a62..c3d1545 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -2128,7 +2128,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
 
 #else				/* !CONFIG_USB_GADGET_DEBUG_FILES */
 
-#define create_proc_file()	do {} while (0)
+#define create_proc_file()	({ (void *)1; })
 #define remove_proc_file()	do {} while (0)
 
 #endif				/* CONFIG_USB_GADGET_DEBUG_FILES */
@@ -2373,9 +2373,14 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
 		ret = -ENOMEM;
 		goto err_unregister;
 	}
-	create_proc_file();
+	if (create_proc_file() == 0) {
+		ret = -ENOMEM;
+		goto err_pool;
+	}
 	return 0;
 
+err_pool:
+	dma_pool_destroy(udc_controller->td_pool);
 err_unregister:
 	device_unregister(&udc_controller->gadget.dev);
 err_free_irq:
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/7] usb: fsl_udc_core: check return value of create_proc_read_entry()
  2010-07-31 17:38 [PATCH 2/7] usb: fsl_udc_core: check return value of create_proc_read_entry() Kulikov Vasiliy
@ 2010-07-31 19:17 ` Dan Carpenter
  2010-08-01  6:19   ` Vasiliy Kulikov
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2010-07-31 19:17 UTC (permalink / raw)
  To: Kulikov Vasiliy
  Cc: David Brownell, Greg Kroah-Hartman, kernel-janitors, linux-kernel,
	linuxppc-dev, linux-usb, Anton Vorontsov, Dinh Nguyen

On Sat, Jul 31, 2010 at 09:38:20PM +0400, Kulikov Vasiliy wrote:
> create_proc_read_entry() may fail, if so return -ENOMEM.
> 

It can fail, but also we return NULL if procfs is disabled.  I haven't
looked at it very carefully, would this patch break the module if procfs
was disabled?

The same applies to the similar patches in this set.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/7] usb: fsl_udc_core: check return value of create_proc_read_entry()
  2010-07-31 19:17 ` Dan Carpenter
@ 2010-08-01  6:19   ` Vasiliy Kulikov
  2010-08-01 10:49     ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Vasiliy Kulikov @ 2010-08-01  6:19 UTC (permalink / raw)
  To: Dan Carpenter, kernel-janitors, Li Yang, David Brownell,
	Greg Kroah-Hartman, Dinh Nguyen, Anton Vorontsov, linux-usb,
	linuxppc-dev, linux-kernel

On Sat, Jul 31, 2010 at 21:17 +0200, Dan Carpenter wrote:
> On Sat, Jul 31, 2010 at 09:38:20PM +0400, Kulikov Vasiliy wrote:
> > create_proc_read_entry() may fail, if so return -ENOMEM.
> > 
> 
> It can fail, but also we return NULL if procfs is disabled.  I haven't
> looked at it very carefully, would this patch break the module if procfs
> was disabled?
Probably you are right, but many drivers in tree compare return value
with NULL. Some of them interpret this as error, some of them simply
call pr_warn("Hmm, I cannot create file in proc, strange..."). Maybe
there is more simplier way to check it without #ifdefs?

> 
> The same applies to the similar patches in this set.
> 
> regards,
> dan carpenter
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/7] usb: fsl_udc_core: check return value of create_proc_read_entry()
  2010-08-01  6:19   ` Vasiliy Kulikov
@ 2010-08-01 10:49     ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2010-08-01 10:49 UTC (permalink / raw)
  To: Vasiliy Kulikov
  Cc: David Brownell, Greg Kroah-Hartman, kernel-janitors, linux-kernel,
	linuxppc-dev, linux-usb, Anton Vorontsov, Dinh Nguyen

On Sun, Aug 01, 2010 at 10:19:34AM +0400, Vasiliy Kulikov wrote:
> On Sat, Jul 31, 2010 at 21:17 +0200, Dan Carpenter wrote:
> > On Sat, Jul 31, 2010 at 09:38:20PM +0400, Kulikov Vasiliy wrote:
> > > create_proc_read_entry() may fail, if so return -ENOMEM.
> > > 
> > 
> > It can fail, but also we return NULL if procfs is disabled.  I haven't
> > looked at it very carefully, would this patch break the module if procfs
> > was disabled?
> Probably you are right, but many drivers in tree compare return value
> with NULL. Some of them interpret this as error, some of them simply
> call pr_warn("Hmm, I cannot create file in proc, strange..."). Maybe
> there is more simplier way to check it without #ifdefs?
> 

If the allocation fails, there is already a warning so no need to add
another.

These things are one time allocation, normally near boot up when memory
is plentifull.  The places that do check should be audited to make sure
there isn't an unneeded dependency on PROC_FS.  I would just leave the
rest.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-01 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-31 17:38 [PATCH 2/7] usb: fsl_udc_core: check return value of create_proc_read_entry() Kulikov Vasiliy
2010-07-31 19:17 ` Dan Carpenter
2010-08-01  6:19   ` Vasiliy Kulikov
2010-08-01 10:49     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).