Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > e9d8bbc0e805c4ae956c373241a517de > files > 3

dkms-pcc-acpi-0.9-3mdv2008.1.src.rpm

Check return value of input_register_device, and fix minor bug (use of
input_unregister_device in wrong place).

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com>

--- dkms-pcc-acpi-0.9/pcc_acpi.c.orig	2008-03-23 21:29:15.000000000 -0300
+++ dkms-pcc-acpi-0.9/pcc_acpi.c	2008-03-23 21:41:05.000000000 -0300
@@ -781,6 +781,7 @@ static int acpi_pcc_init_input(struct ac
 {
 	struct input_dev *hotk_input_dev;
 	struct pcc_keyinput *pcc_keyinput;
+	int err;
 
 	ACPI_FUNCTION_TRACE("acpi_pcc_init_input");
 
@@ -802,7 +803,7 @@ static int acpi_pcc_init_input(struct ac
 
 	if (pcc_keyinput == NULL) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't allocate mem for hotkey"));
-		input_unregister_device(hotk_input_dev);
+		input_free_device(hotk_input_dev);
 		return_VALUE(-ENOMEM);
 	}
 
@@ -831,8 +832,13 @@ static int acpi_pcc_init_input(struct ac
 
 	hotkey->input_dev = hotk_input_dev;
 
-  
-	input_register_device(hotk_input_dev);
+	err = input_register_device(hotk_input_dev);
+	if (err) {
+		input_free_device(hotk_input_dev);
+		hotkey->input_dev = NULL;
+		kfree(pcc_keyinput);
+		return err;
+	}
 
 	return_VALUE(0);
 }