public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Vojtech Pavlik <vojtech@suse.cz>, linux-kernel@vger.kernel.org
Subject: [GIT PATCH 14/18] turbografx: handle errors from input_register_device()
Date: Tue, 31 Jan 2006 23:55:28 -0500	[thread overview]
Message-ID: <20060201050734.894858000.dtor_core@ameritech.net> (raw)
In-Reply-To: 20060201045514.178498000.dtor_core@ameritech.net

[-- Attachment #1: turbografx-error-handling.patch --]
[-- Type: text/plain, Size: 2075 bytes --]

Input: turbografx - handle errors from input_register_device()

Also tgfx_remove shouldn't be marked __exit as it is also called from
__init code.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/joystick/turbografx.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

Index: work/drivers/input/joystick/turbografx.c
===================================================================
--- work.orig/drivers/input/joystick/turbografx.c
+++ work/drivers/input/joystick/turbografx.c
@@ -204,14 +204,14 @@ static struct tgfx __init *tgfx_probe(in
 		if (n_buttons[i] > 6) {
 			printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]);
 			err = -EINVAL;
-			goto err_free_devs;
+			goto err_unreg_devs;
 		}
 
 		tgfx->dev[i] = input_dev = input_allocate_device();
 		if (!input_dev) {
 			printk(KERN_ERR "turbografx.c: Not enough memory for input device\n");
 			err = -ENOMEM;
-			goto err_free_devs;
+			goto err_unreg_devs;
 		}
 
 		tgfx->sticks |= (1 << i);
@@ -238,7 +238,9 @@ static struct tgfx __init *tgfx_probe(in
 		for (j = 0; j < n_buttons[i]; j++)
 			set_bit(tgfx_buttons[j], input_dev->keybit);
 
-		input_register_device(tgfx->dev[i]);
+		err = input_register_device(tgfx->dev[i]);
+		if (err)
+			goto err_free_dev;
 	}
 
         if (!tgfx->sticks) {
@@ -249,9 +251,12 @@ static struct tgfx __init *tgfx_probe(in
 
 	return tgfx;
 
- err_free_devs:
+ err_free_dev:
+	input_free_device(tgfx->dev[i]);
+ err_unreg_devs:
 	while (--i >= 0)
-		input_unregister_device(tgfx->dev[i]);
+		if (tgfx->dev[i])
+			input_unregister_device(tgfx->dev[i]);
  err_free_tgfx:
 	kfree(tgfx);
  err_unreg_pardev:
@@ -262,7 +267,7 @@ static struct tgfx __init *tgfx_probe(in
 	return ERR_PTR(err);
 }
 
-static void __exit tgfx_remove(struct tgfx *tgfx)
+static void tgfx_remove(struct tgfx *tgfx)
 {
 	int i;
 
@@ -300,7 +305,8 @@ static int __init tgfx_init(void)
 
 	if (err) {
 		while (--i >= 0)
-			tgfx_remove(tgfx_base[i]);
+			if (tgfx_base[i])
+				tgfx_remove(tgfx_base[i]);
 		return err;
 	}
 


  parent reply	other threads:[~2006-02-01  5:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-01  4:55 [GIT PATCH 00/18] Input updates for 2.6.16-rc1 Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 01/18] NSLU2 beeper driver Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 02/18] psmouse: set name for Genius mice Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 03/18] iforce: do not return ENOMEM upon successful allocation Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 04/18] mousedev: fix memory leak Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 05/18] Make needlessly global code static Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 06/18] grip: fix crash when accessing device Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 07/18] grip: handle errors from input_register_device() Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 08/18] db9: fix possible crash with Saturn gamepads Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 09/18] db9: handle errors from input_register_device() Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 10/18] sidewinder: fix an oops Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 11/18] sidewinder: handle errors from input_register_device() Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 12/18] gamecon: fix crash when accessing device Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 13/18] gamecon: handle errors from input_register_device() Dmitry Torokhov
2006-02-01  4:55 ` Dmitry Torokhov [this message]
2006-02-01  4:55 ` [GIT PATCH 15/18] tmdc: " Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 16/18] a3d: convert to dynamic input_dev allocation Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 17/18] iforce - fix detection of USB devices Dmitry Torokhov
2006-02-01  4:55 ` [GIT PATCH 18/18] hiddev: fix off-by-one for num_values in uref_multi requests Dmitry Torokhov

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=20060201050734.894858000.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vojtech@suse.cz \
    /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