Commit 2547c387 authored by Chuck Ebbert's avatar Chuck Ebbert Committed by Greg Kroah-Hartman

ACPI: dock: fix opps after dock driver fails to initialize

ACPI: dock: fix opps after dock driver fails to initialize

The driver tests the dock_station pointer for nonnull
to check whether it has initialized properly. But in
some cases dock_station will be non-null after being
freed when driver init fails. Fix by zeroing the
pointer after freeing.
Signed-off-by: default avatarChuck Ebbert <cebbert@redhat.com>
Signed-off-by: default avatarKristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 749de926
...@@ -716,6 +716,7 @@ static int dock_add(acpi_handle handle) ...@@ -716,6 +716,7 @@ static int dock_add(acpi_handle handle)
if (ret) { if (ret) {
printk(KERN_ERR PREFIX "Error %d registering dock device\n", ret); printk(KERN_ERR PREFIX "Error %d registering dock device\n", ret);
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
return ret; return ret;
} }
ret = device_create_file(&dock_device.dev, &dev_attr_docked); ret = device_create_file(&dock_device.dev, &dev_attr_docked);
...@@ -723,6 +724,7 @@ static int dock_add(acpi_handle handle) ...@@ -723,6 +724,7 @@ static int dock_add(acpi_handle handle)
printk("Error %d adding sysfs file\n", ret); printk("Error %d adding sysfs file\n", ret);
platform_device_unregister(&dock_device); platform_device_unregister(&dock_device);
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
return ret; return ret;
} }
ret = device_create_file(&dock_device.dev, &dev_attr_undock); ret = device_create_file(&dock_device.dev, &dev_attr_undock);
...@@ -731,6 +733,7 @@ static int dock_add(acpi_handle handle) ...@@ -731,6 +733,7 @@ static int dock_add(acpi_handle handle)
device_remove_file(&dock_device.dev, &dev_attr_docked); device_remove_file(&dock_device.dev, &dev_attr_docked);
platform_device_unregister(&dock_device); platform_device_unregister(&dock_device);
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
return ret; return ret;
} }
ret = device_create_file(&dock_device.dev, &dev_attr_uid); ret = device_create_file(&dock_device.dev, &dev_attr_uid);
...@@ -738,6 +741,7 @@ static int dock_add(acpi_handle handle) ...@@ -738,6 +741,7 @@ static int dock_add(acpi_handle handle)
printk("Error %d adding sysfs file\n", ret); printk("Error %d adding sysfs file\n", ret);
platform_device_unregister(&dock_device); platform_device_unregister(&dock_device);
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
return ret; return ret;
} }
...@@ -750,6 +754,7 @@ static int dock_add(acpi_handle handle) ...@@ -750,6 +754,7 @@ static int dock_add(acpi_handle handle)
dd = alloc_dock_dependent_device(handle); dd = alloc_dock_dependent_device(handle);
if (!dd) { if (!dd) {
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
ret = -ENOMEM; ret = -ENOMEM;
goto dock_add_err_unregister; goto dock_add_err_unregister;
} }
...@@ -777,6 +782,7 @@ static int dock_add(acpi_handle handle) ...@@ -777,6 +782,7 @@ static int dock_add(acpi_handle handle)
device_remove_file(&dock_device.dev, &dev_attr_undock); device_remove_file(&dock_device.dev, &dev_attr_undock);
platform_device_unregister(&dock_device); platform_device_unregister(&dock_device);
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
return ret; return ret;
} }
...@@ -810,6 +816,7 @@ static int dock_remove(void) ...@@ -810,6 +816,7 @@ static int dock_remove(void)
/* free dock station memory */ /* free dock station memory */
kfree(dock_station); kfree(dock_station);
dock_station = NULL;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment