提交 59f91ff1 编写于 作者: H Henrique de Moraes Holschuh 提交者: Len Brown

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: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Tested-by: NMike Kershaw <dragorn@kismetwireless.net>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 4273af8d
...@@ -4817,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp) ...@@ -4817,9 +4817,15 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
unsigned int i; unsigned int i;
struct ibm_struct *ibm; struct ibm_struct *ibm;
if (!kp || !kp->name || !val)
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
ibm = ibms_init[i].data; ibm = ibms_init[i].data;
BUG_ON(ibm == NULL); WARN_ON(ibm == NULL);
if (!ibm || !ibm->name)
continue;
if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { if (strcmp(ibm->name, kp->name) == 0 && ibm->write) {
if (strlen(val) > sizeof(ibms_init[i].param) - 2) if (strlen(val) > sizeof(ibms_init[i].param) - 2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册