Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=368d290ba2a66338303b5d3998b182e404a9eb38 Commit: 368d290ba2a66338303b5d3998b182e404a9eb38 Parent: d624284b06f869dad87a70a8d0cad72fbf7527b9 Author: Dirk Hohndel <[EMAIL PROTECTED]> AuthorDate: Tue Oct 30 13:02:44 2007 +0100 Committer: Jiri Kosina <[EMAIL PROTECTED]> CommitDate: Wed Oct 31 13:30:35 2007 +0100
HID: fix hidinput_connect ignoring retval from input_register_device hidinput_connect() ignores retval from input_register_device(). Fix it by properly undoing all the registrations that have been already done, and return error. Signed-off-by: Dirk Hohndel <[EMAIL PROTECTED]> Signed-off-by: Jiri Kosina <[EMAIL PROTECTED]> --- 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..71eb769 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); - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html