public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kulikov Vasiliy <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: David Brownell <dbrownell@users.sourceforge.net>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Tony Lindgren <tony@atomide.com>,
	Cory Maccarrone <darkstar6262@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] usb: omap_udc: check return value of proc_create()
Date: Sat, 31 Jul 2010 21:39:24 +0400	[thread overview]
Message-ID: <1280597965-8525-1-git-send-email-segooon@gmail.com> (raw)

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

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 drivers/usb/gadget/omap_udc.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index f81e4f0..1083216 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2544,9 +2544,9 @@ static const struct file_operations proc_ops = {
 	.release	= single_release,
 };
 
-static void create_proc_file(void)
+static int create_proc_file(void)
 {
-	proc_create(proc_filename, 0, NULL, &proc_ops);
+	return (proc_create(proc_filename, 0, NULL, &proc_ops) == NULL);
 }
 
 static void remove_proc_file(void)
@@ -2556,7 +2556,7 @@ static void remove_proc_file(void)
 
 #else
 
-static inline void create_proc_file(void) {}
+static inline int create_proc_file(void) { return 0; }
 static inline void remove_proc_file(void) {}
 
 #endif
@@ -2998,13 +2998,19 @@ known:
 #endif
 	}
 
-	create_proc_file();
+	if (create_proc_file()) {
+		status = -ENOMEM;
+		goto cleanup3;
+	}
+
 	status = device_add(&udc->gadget.dev);
 	if (!status)
 		return status;
 	/* If fail, fall through */
-#ifdef	USE_ISO
+
+	remove_proc_file();
 cleanup3:
+#ifdef	USE_ISO
 	free_irq(pdev->resource[2].start, udc);
 #endif
 
-- 
1.7.0.4


             reply	other threads:[~2010-07-31 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-31 17:39 Kulikov Vasiliy [this message]
2010-08-01 10:06 ` [PATCH 5/7] usb: omap_udc: check return value of proc_create() Sergei Shtylyov
2010-08-01 11:29   ` Remove me!!!! Yehuda Mor
2010-08-01 12:46     ` Valeo de Vries
2010-08-01 15:16     ` trapDoor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280597965-8525-1-git-send-email-segooon@gmail.com \
    --to=segooon@gmail.com \
    --cc=darkstar6262@gmail.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=gregkh@suse.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox