Skip to contentSkip to conversation

hp-wmi: add return value checking for input_allocate_device()

PATCH In review Axel Lin 2 participants 4 messages Jul 6, 2010 x86 platform drivers

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 hp-wmi: add return value checking for input_allocate_device()

Add error checking and return -ENOMEM if input_allocate_device() fail.

---
 drivers/platform/x86/hp-wmi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/platform/x86/hp-wmi.c +2 -0
index 51c07a0..c508e20 100644
@@ -402,6 +402,8 @@ static int __init hp_wmi_input_setup(void)
 	int err;
 
 	hp_wmi_input_dev = input_allocate_device();
+	if (!hp_wmi_input_dev)
+		return -ENOMEM;
 
 	hp_wmi_input_dev->name = "HP WMI hotkeys";
 	hp_wmi_input_dev->phys = "wmi/input0";
Signature · 1 line
1.5.4.3
#1 lore raw

Hi,

it's incredible how much cleanups and fixes you find in this handful of drivers... It's very much appreciated!

Quoted 12 lines · On Tuesday 06 July 2010 04:30:26 Axel Lin wrote:

Add error checking and return -ENOMEM if input_allocate_device() fail.

---
 drivers/platform/x86/hp-wmi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/platform/x86/hp-wmi.c +0 -0
index 51c07a0..c508e20 100644

drivers/platform/x86/hp-wmi.c static int __init hp_wmi_input_setup(void) · line 409

Quoted 8 lines
drivers/platform/x86/hp-wmi.c +2 -0
@@ -402,6 +402,8 @@ static int __init hp_wmi_input_setup(void)
 	int err;
 
 	hp_wmi_input_dev = input_allocate_device();
+	if (!hp_wmi_input_dev)
+		return -ENOMEM;
 
 	hp_wmi_input_dev->name = "HP WMI hotkeys";
 	hp_wmi_input_dev->phys = "wmi/input0";

But also hp_wmi_input_setup() call should get checked and if it fails, the previous wmi_install_notify_handler() must get uninstalled again. Hm, probably the whole driver shouldn't load then and the error code from hp_wmi_input_setup() can be returned in hp_wmi_init(void).

Do you mind to incorporate above if you agree.

Thanks,

Thomas

author
#2 lore raw

hi Thomas,
2010/7/6 Thomas Renninger <[email protected]>:

Quoted 32 lines

Hi,

it's incredible how much cleanups and fixes you find in this handful of drivers... It's very much appreciated!

Quoted 12 lines · On Tuesday 06 July 2010 04:30:26 Axel Lin wrote:

Add error checking and return -ENOMEM if input_allocate_device() fail.

---
 drivers/platform/x86/hp-wmi.c |    2 ++

 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/platform/x86/hp-wmi.c +0 -0
index 51c07a0..c508e20 100644

drivers/platform/x86/hp-wmi.c static int __init hp_wmi_input_setup(void) · line 409

Quoted 8 lines
drivers/platform/x86/hp-wmi.c +2 -0
@@ -402,6 +402,8 @@ static int __init hp_wmi_input_setup(void)
       int err;
 
       hp_wmi_input_dev = input_allocate_device();
+     if (!hp_wmi_input_dev)
+             return -ENOMEM;
 
       hp_wmi_input_dev->name = "HP WMI hotkeys";
       hp_wmi_input_dev->phys = "wmi/input0";

But also hp_wmi_input_setup() call should get checked and if it fails, the previous wmi_install_notify_handler() must get uninstalled again. Hm, probably the whole driver shouldn't load then and the error code from hp_wmi_input_setup() can be returned in hp_wmi_init(void).

Quoted 1 line

Do you mind to incorporate above if you agree.

Checking hp_wmi_input_setup() is already done in my previous patch. ( which is already merged in platform-driver-x86 tree.
http://git.kernel.org/?p=linux/kernel/git/mjg59/platform-drivers-x86.git;a=commitdiff;h=b035d5f9fcb6cd6bba44b764b17d885f4d960d37
).
Thus this patch only adds the return value checking for input_allocate_device() in hp_wmi_input_setup().

Regards,
Axel

Quoted 5 lines

Thanks,

  Thomas

#3 lore raw
Quoted 2 lines · On Tuesday 06 July 2010 10:07:49 Axel Lin wrote:

hi Thomas,
2010/7/6 Thomas Renninger <[email protected]>:

...

Quoted 4 lines
Quoted 1 line

Do you mind to incorporate above if you agree.

Checking hp_wmi_input_setup() is already done in my previous patch. ( which is already merged in platform-driver-x86 tree.

...
Perfect!

Thomas