aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-11-18 06:18:29 -0500
committerLen Brown <len.brown@intel.com>2007-11-19 16:10:04 -0500
commit59f91ff11e594913a5b3c03a4707fdf02338c8df (patch)
tree112aedb786b0785972f55853157ebe4752fc6265 /drivers
parent4273af8d08c823d5898a2b1c2d0f25b4a8b9eaee (diff)
ACPI: thinkpad-acpi: fix oops when a module parameter has no value
set_ibm_param() could OOPS with a NULL pointer derreference if one did not give any values for a module parameter it handles. This would, of course, cause all sort of trouble for future modprobing and require a reboot to clean up properly. Fix it by returning -EINVAL if no values are given for the parameter, and also avoid any nastyness from BUG_ON while at it. How to reproduce: modprobe thinkpad-acpi brightness Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Tested-by: Mike Kershaw <dragorn@kismetwireless.net> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/thinkpad_acpi.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 8c9430775285..ab23a3221585 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -4817,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
4817 unsigned int i; 4817 unsigned int i;
4818 struct ibm_struct *ibm; 4818 struct ibm_struct *ibm;
4819 4819
4820 if (!kp || !kp->name || !val)
4821 return -EINVAL;
4822
4820 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { 4823 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
4821 ibm = ibms_init[i].data; 4824 ibm = ibms_init[i].data;
4822 BUG_ON(ibm == NULL); 4825 WARN_ON(ibm == NULL);
4826
4827 if (!ibm || !ibm->name)
4828 continue;
4823 4829
4824 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { 4830 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) {
4825 if (strlen(val) > sizeof(ibms_init[i].param) - 2) 4831 if (strlen(val) > sizeof(ibms_init[i].param) - 2)