Skip to content

Commit

Permalink
hp-wmi: clear rfkill device pointers when appropriate
Browse files Browse the repository at this point in the history
NULLify rfkill pointers during initialization. This prevents dereference
of invalid pointer in case the driver is rebound and some rfkill device
isn't detected anymore. Clear them also in hp_wmi_rfkill_setup failure
path so that an rfkill initialization failure doesn't need to be fatal
for the whole driver.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
  • Loading branch information
Anssi Hannula authored and Matthew Garrett committed Mar 28, 2011
1 parent eceb7bd commit 6d97db5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/platform/x86/hp-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,21 +587,29 @@ static int __devinit hp_wmi_rfkill_setup(struct platform_device *device)
return 0;
register_wwan_err:
rfkill_destroy(wwan_rfkill);
wwan_rfkill = NULL;
if (bluetooth_rfkill)
rfkill_unregister(bluetooth_rfkill);
register_bluetooth_error:
rfkill_destroy(bluetooth_rfkill);
bluetooth_rfkill = NULL;
if (wifi_rfkill)
rfkill_unregister(wifi_rfkill);
register_wifi_error:
rfkill_destroy(wifi_rfkill);
wifi_rfkill = NULL;
return err;
}

static int __devinit hp_wmi_bios_setup(struct platform_device *device)
{
int err;

/* clear detected rfkill devices */
wifi_rfkill = NULL;
bluetooth_rfkill = NULL;
wwan_rfkill = NULL;

err = hp_wmi_rfkill_setup(device);
if (err)
return err;
Expand Down

0 comments on commit 6d97db5

Please sign in to comment.