diff options
author | Libo Chen <clbchenlibo.chen@huawei.com> | 2013-05-19 22:30:07 -0400 |
---|---|---|
committer | Matthew Garrett <matthew.garrett@nebula.com> | 2013-07-10 15:42:40 -0400 |
commit | 4c241b364b5899e46924bfd4f9599c45f8e4a146 (patch) | |
tree | 9352efcdf1ce7c96219ff4867dab41b8318ae268 /drivers/platform | |
parent | e1a98e61c21694c9c690c7f253010cd44e89e7fd (diff) |
x86: msi-laptop: fix memleak
1. fix two visible mistakes:
* when load_scm_model_init faild, we should call platform_device_del(msipf_device)
* msipf_attribute_group should be remove in err case
2. change some tags, give them real meaning.
Signed-off-by: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/msi-laptop.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c index 6b2293875672..62f8030b9e77 100644 --- a/drivers/platform/x86/msi-laptop.c +++ b/drivers/platform/x86/msi-laptop.c | |||
@@ -1098,29 +1098,29 @@ static int __init msi_init(void) | |||
1098 | 1098 | ||
1099 | ret = platform_device_add(msipf_device); | 1099 | ret = platform_device_add(msipf_device); |
1100 | if (ret) | 1100 | if (ret) |
1101 | goto fail_platform_device1; | 1101 | goto fail_device_add; |
1102 | 1102 | ||
1103 | if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) { | 1103 | if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) { |
1104 | ret = -EINVAL; | 1104 | ret = -EINVAL; |
1105 | goto fail_platform_device1; | 1105 | goto fail_scm_model_init; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | ret = sysfs_create_group(&msipf_device->dev.kobj, | 1108 | ret = sysfs_create_group(&msipf_device->dev.kobj, |
1109 | &msipf_attribute_group); | 1109 | &msipf_attribute_group); |
1110 | if (ret) | 1110 | if (ret) |
1111 | goto fail_platform_device2; | 1111 | goto fail_create_group; |
1112 | 1112 | ||
1113 | if (!quirks->old_ec_model) { | 1113 | if (!quirks->old_ec_model) { |
1114 | if (threeg_exists) | 1114 | if (threeg_exists) |
1115 | ret = device_create_file(&msipf_device->dev, | 1115 | ret = device_create_file(&msipf_device->dev, |
1116 | &dev_attr_threeg); | 1116 | &dev_attr_threeg); |
1117 | if (ret) | 1117 | if (ret) |
1118 | goto fail_platform_device2; | 1118 | goto fail_create_attr; |
1119 | } else { | 1119 | } else { |
1120 | ret = sysfs_create_group(&msipf_device->dev.kobj, | 1120 | ret = sysfs_create_group(&msipf_device->dev.kobj, |
1121 | &msipf_old_attribute_group); | 1121 | &msipf_old_attribute_group); |
1122 | if (ret) | 1122 | if (ret) |
1123 | goto fail_platform_device2; | 1123 | goto fail_create_attr; |
1124 | 1124 | ||
1125 | /* Disable automatic brightness control by default because | 1125 | /* Disable automatic brightness control by default because |
1126 | * this module was probably loaded to do brightness control in | 1126 | * this module was probably loaded to do brightness control in |
@@ -1134,26 +1134,22 @@ static int __init msi_init(void) | |||
1134 | 1134 | ||
1135 | return 0; | 1135 | return 0; |
1136 | 1136 | ||
1137 | fail_platform_device2: | 1137 | fail_create_attr: |
1138 | 1138 | sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group); | |
1139 | fail_create_group: | ||
1139 | if (quirks->load_scm_model) { | 1140 | if (quirks->load_scm_model) { |
1140 | i8042_remove_filter(msi_laptop_i8042_filter); | 1141 | i8042_remove_filter(msi_laptop_i8042_filter); |
1141 | cancel_delayed_work_sync(&msi_rfkill_dwork); | 1142 | cancel_delayed_work_sync(&msi_rfkill_dwork); |
1142 | cancel_work_sync(&msi_rfkill_work); | 1143 | cancel_work_sync(&msi_rfkill_work); |
1143 | rfkill_cleanup(); | 1144 | rfkill_cleanup(); |
1144 | } | 1145 | } |
1146 | fail_scm_model_init: | ||
1145 | platform_device_del(msipf_device); | 1147 | platform_device_del(msipf_device); |
1146 | 1148 | fail_device_add: | |
1147 | fail_platform_device1: | ||
1148 | |||
1149 | platform_device_put(msipf_device); | 1149 | platform_device_put(msipf_device); |
1150 | |||
1151 | fail_platform_driver: | 1150 | fail_platform_driver: |
1152 | |||
1153 | platform_driver_unregister(&msipf_driver); | 1151 | platform_driver_unregister(&msipf_driver); |
1154 | |||
1155 | fail_backlight: | 1152 | fail_backlight: |
1156 | |||
1157 | backlight_device_unregister(msibl_device); | 1153 | backlight_device_unregister(msibl_device); |
1158 | 1154 | ||
1159 | return ret; | 1155 | return ret; |