All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dirk Hohndel <hohndel@linux.intel.com>
To: Jiri Kosina <jikos@jikos.cz>
Cc: Jeff Garzik <jeff@garzik.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-input@atrey.karlin.mff.cuni.cz,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] INPUT: fix hidinput_connect ignoring retval from input_register_device
Date: Mon, 29 Oct 2007 15:50:51 -0700	[thread overview]
Message-ID: <20071029225051.GA1473@linux.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0710291827140.18815@twin.jikos.cz>

[sorry - mail config screwup caused this to bounce for the more restrictive
of the recipient addresses, including the mailing lists, so resending again]

On Mon, Oct 29, 2007 at 06:28:36PM +0100, Jiri Kosina wrote:                                                                                                                 
>                                                                                                                                                                            
> > Would something like this work?                                                                                                                                          
>                                                                                                                                                                            
> Yes, I think that this patch is in principle fine, modulo the redundant                                                                                                    
> NULL-ptr checks.                                                                                                                                                           
                                                                                                                                                                             
Thanks everyone with helping me to get this right! Which I hope this one is :-)                                                                                              
                                                                                                                                                                             
/D                                                                                                                                                                           


[PATCH] hidinput_connect ignores retval from input_register_device

signed-off-by: Dirk Hohndel <hohndel@linux.intel.com>

---
 drivers/hid/hid-input.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index dd332f2..aa9b52d 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1152,7 +1152,7 @@ int hidinput_connect(struct hid_device *hid)
 					kfree(hidinput);
 					input_free_device(input_dev);
 					err_hid("Out of memory during hid input probe");
-					return -1;
+					goto out_unwind;
 				}
 
 				input_set_drvdata(input_dev, hid);
@@ -1186,15 +1186,25 @@ int hidinput_connect(struct hid_device *hid)
 				 * UGCI) cram a lot of unrelated inputs into the
 				 * same interface. */
 				hidinput->report = report;
-				input_register_device(hidinput->input);
+				if (input_register_device(hidinput->input))
+					goto out_cleanup;
 				hidinput = NULL;
 			}
 		}
 
-	if (hidinput)
-		input_register_device(hidinput->input);
+	if (hidinput && input_register_device(hidinput->input))
+		goto out_cleanup;
 
 	return 0;
+
+out_cleanup:
+	input_free_device(hidinput->input);
+	kfree(hidinput);
+out_unwind:
+	/* unwind the ones we already registered */
+	hidinput_disconnect(hid);
+
+	return -1;
 }
 EXPORT_SYMBOL_GPL(hidinput_connect);
 
-- 
gitgui.0.8.4.g8d863

      reply	other threads:[~2007-10-29 22:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-29  6:51 [PATCH] INPUT: fix hidinput_connect ignoring retval from input_register_device Dirk Hohndel
2007-10-29  7:53 ` Jeff Garzik
2007-10-29  8:49   ` Dirk Hohndel
2007-10-29  9:35     ` Jeff Garzik
2007-10-29 10:14     ` Jiri Kosina
2007-10-29 12:54       ` Dmitry Torokhov
2007-10-29 12:57         ` Jiri Kosina
2007-10-29 14:49         ` Jeff Garzik
2007-10-29 15:20           ` Dirk Hohndel
2007-10-29 15:33             ` Dmitry Torokhov
2007-10-29 15:38               ` Hohndel, Dirk
2007-10-29 17:11                 ` Dmitry Torokhov
2007-10-29 17:28             ` Jiri Kosina
2007-10-29 22:50               ` Dirk Hohndel [this message]

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=20071029225051.GA1473@linux.intel.com \
    --to=hohndel@linux.intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jeff@garzik.org \
    --cc=jikos@jikos.cz \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.