Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hp-wmi: check for allocation failures

rfkill_alloc() returns NULL on failure. Check for it, to make the
static checkers happy.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>

authored by

Dan Carpenter and committed by
Matthew Garrett
dd258c00 121b7b0d

+10
+10
drivers/platform/x86/hp-wmi.c
··· 634 634 RFKILL_TYPE_WLAN, 635 635 &hp_wmi_rfkill_ops, 636 636 (void *) HPWMI_WIFI); 637 + if (!wifi_rfkill) 638 + return -ENOMEM; 637 639 rfkill_init_sw_state(wifi_rfkill, 638 640 hp_wmi_get_sw_state(HPWMI_WIFI)); 639 641 rfkill_set_hw_state(wifi_rfkill, ··· 650 648 RFKILL_TYPE_BLUETOOTH, 651 649 &hp_wmi_rfkill_ops, 652 650 (void *) HPWMI_BLUETOOTH); 651 + if (!bluetooth_rfkill) { 652 + err = -ENOMEM; 653 + goto register_wifi_error; 654 + } 653 655 rfkill_init_sw_state(bluetooth_rfkill, 654 656 hp_wmi_get_sw_state(HPWMI_BLUETOOTH)); 655 657 rfkill_set_hw_state(bluetooth_rfkill, ··· 668 662 RFKILL_TYPE_WWAN, 669 663 &hp_wmi_rfkill_ops, 670 664 (void *) HPWMI_WWAN); 665 + if (!wwan_rfkill) { 666 + err = -ENOMEM; 667 + goto register_bluetooth_error; 668 + } 671 669 rfkill_init_sw_state(wwan_rfkill, 672 670 hp_wmi_get_sw_state(HPWMI_WWAN)); 673 671 rfkill_set_hw_state(wwan_rfkill,