Skip to content

Commit

Permalink
x86/olpc/xo1/sci: Don't call input_free_device() after input_unregist…
Browse files Browse the repository at this point in the history
…er_device()

input_free_device() should only be used if
input_register_device() was not called yet or if it failed. Once
device was unregistered use input_unregister_device() and memory
will be freed once last reference to the device is dropped.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Cc: dsd@laptop.org
Cc: pgf@laptop.org
Cc: gregkh@linuxfoundation.org
Link: http://lkml.kernel.org/r/CAPgLHd84cboeucog%2BYNdHvGqTfTROujDKZgSkh3o0B-Q93ee2A@mail.gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Wei Yongjun authored and Ingo Molnar committed Apr 24, 2013
1 parent ad0304c commit 3482e66
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions arch/x86/platform/olpc/olpc-xo1-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ static int setup_power_button(struct platform_device *pdev)
static void free_power_button(void)
{
input_unregister_device(power_button_idev);
input_free_device(power_button_idev);
}

static int setup_ebook_switch(struct platform_device *pdev)
Expand Down Expand Up @@ -491,7 +490,6 @@ static int setup_ebook_switch(struct platform_device *pdev)
static void free_ebook_switch(void)
{
input_unregister_device(ebook_switch_idev);
input_free_device(ebook_switch_idev);
}

static int setup_lid_switch(struct platform_device *pdev)
Expand Down Expand Up @@ -526,6 +524,7 @@ static int setup_lid_switch(struct platform_device *pdev)

err_create_attr:
input_unregister_device(lid_switch_idev);
lid_switch_idev = NULL;
err_register:
input_free_device(lid_switch_idev);
return r;
Expand All @@ -535,7 +534,6 @@ static void free_lid_switch(void)
{
device_remove_file(&lid_switch_idev->dev, &dev_attr_lid_wake_mode);
input_unregister_device(lid_switch_idev);
input_free_device(lid_switch_idev);
}

static int xo1_sci_probe(struct platform_device *pdev)
Expand Down

0 comments on commit 3482e66

Please sign in to comment.