diff options
author | Dirk Hohndel <hohndel@linux.intel.com> | 2007-10-30 08:02:44 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2007-10-31 08:30:35 -0400 |
commit | 368d290ba2a66338303b5d3998b182e404a9eb38 (patch) | |
tree | 8c26ffd8f36e1ef1f0533f20b0018919a029a83b /drivers/hid | |
parent | d624284b06f869dad87a70a8d0cad72fbf7527b9 (diff) |
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 <hohndel@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | 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 dd332f28e08c..71eb7693e453 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -1152,7 +1152,7 @@ int hidinput_connect(struct hid_device *hid) | |||
1152 | kfree(hidinput); | 1152 | kfree(hidinput); |
1153 | input_free_device(input_dev); | 1153 | input_free_device(input_dev); |
1154 | err_hid("Out of memory during hid input probe"); | 1154 | err_hid("Out of memory during hid input probe"); |
1155 | return -1; | 1155 | goto out_unwind; |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | input_set_drvdata(input_dev, hid); | 1158 | input_set_drvdata(input_dev, hid); |
@@ -1186,15 +1186,25 @@ int hidinput_connect(struct hid_device *hid) | |||
1186 | * UGCI) cram a lot of unrelated inputs into the | 1186 | * UGCI) cram a lot of unrelated inputs into the |
1187 | * same interface. */ | 1187 | * same interface. */ |
1188 | hidinput->report = report; | 1188 | hidinput->report = report; |
1189 | input_register_device(hidinput->input); | 1189 | if (input_register_device(hidinput->input)) |
1190 | goto out_cleanup; | ||
1190 | hidinput = NULL; | 1191 | hidinput = NULL; |
1191 | } | 1192 | } |
1192 | } | 1193 | } |
1193 | 1194 | ||
1194 | if (hidinput) | 1195 | if (hidinput && input_register_device(hidinput->input)) |
1195 | input_register_device(hidinput->input); | 1196 | goto out_cleanup; |
1196 | 1197 | ||
1197 | return 0; | 1198 | return 0; |
1199 | |||
1200 | out_cleanup: | ||
1201 | input_free_device(hidinput->input); | ||
1202 | kfree(hidinput); | ||
1203 | out_unwind: | ||
1204 | /* unwind the ones we already registered */ | ||
1205 | hidinput_disconnect(hid); | ||
1206 | |||
1207 | return -1; | ||
1198 | } | 1208 | } |
1199 | EXPORT_SYMBOL_GPL(hidinput_connect); | 1209 | EXPORT_SYMBOL_GPL(hidinput_connect); |
1200 | 1210 | ||