Add patches accepted for 2.6.24-rc4
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.24-rc4 / 0008-ACPI-thinkpad-acpi-fix-oops-when-a-module-paramete.patch
blob3d39283996414d8d6dc368f98a9c3c2ae5df0fe7
1 From 59f91ff11e594913a5b3c03a4707fdf02338c8df Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sun, 18 Nov 2007 09:18:29 -0200
4 Subject: [PATCH 23/23] ACPI: thinkpad-acpi: fix oops when a module parameter has no value
6 set_ibm_param() could OOPS with a NULL pointer derreference if one did not give
7 any values for a module parameter it handles. This would, of course, cause all
8 sort of trouble for future modprobing and require a reboot to clean up
9 properly.
11 Fix it by returning -EINVAL if no values are given for the parameter, and also
12 avoid any nastyness from BUG_ON while at it.
14 How to reproduce: modprobe thinkpad-acpi brightness
16 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
17 Tested-by: Mike Kershaw <dragorn@kismetwireless.net>
18 Signed-off-by: Len Brown <len.brown@intel.com>
19 ---
20 drivers/misc/thinkpad_acpi.c | 8 +++++++-
21 1 files changed, 7 insertions(+), 1 deletions(-)
23 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
24 index 8c94307..ab23a32 100644
25 --- a/drivers/misc/thinkpad_acpi.c
26 +++ b/drivers/misc/thinkpad_acpi.c
27 @@ -4817,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
28 unsigned int i;
29 struct ibm_struct *ibm;
31 + if (!kp || !kp->name || !val)
32 + return -EINVAL;
34 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
35 ibm = ibms_init[i].data;
36 - BUG_ON(ibm == NULL);
37 + WARN_ON(ibm == NULL);
39 + if (!ibm || !ibm->name)
40 + continue;
42 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) {
43 if (strlen(val) > sizeof(ibms_init[i].param) - 2)
44 --
45 1.5.3.4