Re: [ibm-acpi-devel] [PATCH] thinkpad-acpi: recognize latestV-Series using DMI_BIOS_VENDOR

From: Henrique de Moraes Holschuh
Date: Mon Aug 06 2012 - 17:33:18 EST


On Mon, 06 Aug 2012, manoj.iyer@xxxxxxxxxxxxx wrote:
> In the latest V-series bios DMI_PRODUCT_VERSION does not contain
> the string Lenovo or Thinkpad, but is set to the model number, this
> causes the thinkpad_acpi module to fail to load. Recognize laptop
> as Lenovo using DMI_BIOS_VENDOR instead, which is set to Lenovo.
>
> Signed-off-by: Manoj Iyer <manoj.iyer@xxxxxxxxxxxxx>
> ---
> drivers/platform/x86/thinkpad_acpi.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index e7f7328..17692c8 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -8658,11 +8658,16 @@ static int __must_check __init get_thinkpad_model_data(
> }
>
> s = dmi_get_system_info(DMI_PRODUCT_VERSION);
> - if (s && !(strnicmp(s, "ThinkPad", 8) && strnicmp(s, "Lenovo", 6))) {
> + if (s && !(strnicmp(s, "ThinkPad", 8) && strnicmp(s, "Lenovo", 6)))
> tp->model_str = kstrdup(s, GFP_KERNEL);
> - if (!tp->model_str)
> - return -ENOMEM;
> - }
> + else {
> + s = dmi_get_system_info(DMI_BIOS_VENDOR);
> + if (s && !(strnicmp(s, "Lenovo", 6)))
> + tp->model_str = kstrdup(s, GFP_KERNEL);
> + }
> +
> + if (!tp->model_str)
> + return -ENOMEM;

This last unguarded if() can cause problems, s is allowed to be NULL. Just
leave it where it was, and add a second one to the new "else" branch.

--
"One disk to rule them all, One disk to find them. One disk to bring
them all and in the darkness grind them. In the Land of Redmond
where the shadows lie." -- The Silicon Valley Tarot
Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/