From patchwork Tue Sep 3 08:35:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13788283 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFFD52139DF for ; Tue, 3 Sep 2024 08:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725352546; cv=none; b=LFmFRDhD0Sdgj3qNv/a3SLVNL+vekIox8MaTCDaYip3KkJAK41tNW9BFqWEZ2N7jNmzVBrVS8rKPQ8M4hJ1ASPWEL905EaSVF7rIQbGgA/PYgGBGrOwI37SOqVmTlHqTgFsGWO0QCt4u0KzxwFK9ibj6cVr6FSrxJgRZuFNu5B8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725352546; c=relaxed/simple; bh=ziUG70faR0quCW/2FgjfDs/hgpCgYjzxYf77513XEQ0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TvbxoVCMOz+2onWAFyBOBy06u1t3Id5CuQxPoYjhNCU6YWkDr5bwDXrpq8PZpa/otV3sixGupvnUOSHUG+lTo8s5hNCoTWozI4MBEIZsiVdzcaXR7MrLFiJfzIbkNlNRz8Z+jyeWrlPi+Rv9ex++0G9mIR4d87iHn/XBQbSABps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IByCM5gE; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IByCM5gE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725352543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=IomLyH4785d5OQRSi6Z9hL3WWNcAfSNhIiGUhUVIycc=; b=IByCM5gEBM2ghmGC/YpRXxfO1/+g/NQeXwJYd8ueq4Lf0uLdkjdJFNsjIUSl20hZrA8npq sn6csXD4Rz6nRbZv9ktABaMj0N+1hZAjX8t0PHR8XDui5yNYVR0mtjQ7fFkgXxm09gnkCB y5I7JzZizBec8saFheXB0sTls2oWCAA= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-Z6A0bKYaPGWYnVQSK0hL6g-1; Tue, 03 Sep 2024 04:35:42 -0400 X-MC-Unique: Z6A0bKYaPGWYnVQSK0hL6g-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 96D041955F06; Tue, 3 Sep 2024 08:35:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.239]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C0811956048; Tue, 3 Sep 2024 08:35:39 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , James Harmison , platform-driver-x86@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/3] platform/x86: panasonic-laptop: Check minimum SQTY value Date: Tue, 3 Sep 2024 10:35:31 +0200 Message-ID: <20240903083533.9403-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 The panasonic laptop code in various places uses the sinf array with index values of 0 - SINF_CUR_BRIGHT(0x0d) without checking that the sinf array is big enough. Check for a minimum SQTY value of SINF_CUR_BRIGHT to avoid out of bounds accesses of the sinf array. Note SQTY returning SINF_CUR_BRIGHT is ok because the driver adds one extra entry to the sinf array. Fixes: e424fb8cc4e6 ("panasonic-laptop: avoid overflow in acpi_pcc_hotkey_add()") Cc: stable@vger.kernel.org Tested-by: James Harmison Signed-off-by: Hans de Goede --- drivers/platform/x86/panasonic-laptop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index cf845ee1c7b1..d7f9017a5a13 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c @@ -963,8 +963,8 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) num_sifr = acpi_pcc_get_sqty(device); - if (num_sifr < 0 || num_sifr > 255) { - pr_err("num_sifr out of range"); + if (num_sifr < SINF_CUR_BRIGHT || num_sifr > 255) { + pr_err("num_sifr %d out of range %d - 255\n", num_sifr, SINF_CUR_BRIGHT); return -ENODEV; } From patchwork Tue Sep 3 08:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13788285 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FCAE200116 for ; Tue, 3 Sep 2024 08:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725352588; cv=none; b=h7dyyCArqTo5E8HfInxbKNTMUIcLsTUuUKmHtY3TUjRcVf5dChL3ItyO/4kzdr/QmfCBOBpGZrerXErpG8BDJej81b4/3gb040Fjkao22gVGDsd639Hbm6bHwd8f9wmmvfZC8CxGTlXwuF0uaCH2NBI9qOk/RqPDFPiCtOoVx5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725352588; c=relaxed/simple; bh=B96nrPrJ3UymOWx1erMliiY9Qfz6nxNgEcrD5Gbf74I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CiKJJBGj2gm5TPc9Vl2fA3t7M5E6ldVbQqSSfkwDdVdzvYeuNbKt8OvGH9S65H4SmDmTEJThWL1QbmM1pmQMLc1z5/XfyIAPZm8LPV8oYQBT+qT3ecC1BNzUjBiZr1BI8yFs4mDpb/afLhZUQGNqt0mA4nFoRsf3l1JZ4RYlLko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bH4NXZRv; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bH4NXZRv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725352586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kz0l3l801CIquS+C9tcccCqk1x8Ol6UO6XryxHIY3hg=; b=bH4NXZRvZCSpEoYCuHNdQyWcJAWG4w+7YghD7IXHIeICCHechyHXRgzvWe1mKil1Kgm6+O 7nL+m7sBKJnHp6lYRYGrrOUmGJ7CcA8WJQEL/v3oq9Iazxv+KUpVgn+P5b3As+dNLkQJdA FKRwENe3/NbTNnlvw01810JUYpRraZ4= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-275-ax4uaVoFO_eLl22emilK8w-1; Tue, 03 Sep 2024 04:35:45 -0400 X-MC-Unique: ax4uaVoFO_eLl22emilK8w-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EF6571955D47; Tue, 3 Sep 2024 08:35:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.239]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F1101956048; Tue, 3 Sep 2024 08:35:41 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , James Harmison , platform-driver-x86@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/3] platform/x86: panasonic-laptop: Allocate 1 entry extra in the sinf array Date: Tue, 3 Sep 2024 10:35:32 +0200 Message-ID: <20240903083533.9403-2-hdegoede@redhat.com> In-Reply-To: <20240903083533.9403-1-hdegoede@redhat.com> References: <20240903083533.9403-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Some DSDT-s have an of by one bug where the SINF package count is one higher then the SQTY reported value, allocate 1 entry extra. Also make the SQTY <-> SINF package count mismatch error more verbose to help debugging similar issues in the future. This fixes the panasonic-laptop driver failing to probe() on some devices with the following errors: [ 3.958887] SQTY reports bad SINF length SQTY: 37 SINF-pkg-count: 38 [ 3.958892] Couldn't retrieve BIOS data [ 3.983685] Panasonic Laptop Support - With Macros: probe of MAT0019:00 failed with error -5 Fixes: 709ee531c153 ("panasonic-laptop: add Panasonic Let's Note laptop extras driver v0.94") Cc: stable@vger.kernel.org Tested-by: James Harmison Signed-off-by: Hans de Goede --- drivers/platform/x86/panasonic-laptop.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index d7f9017a5a13..4c9e20e1afe8 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c @@ -337,7 +337,8 @@ static int acpi_pcc_retrieve_biosdata(struct pcc_acpi *pcc) } if (pcc->num_sifr < hkey->package.count) { - pr_err("SQTY reports bad SINF length\n"); + pr_err("SQTY reports bad SINF length SQTY: %ld SINF-pkg-count: %d\n", + pcc->num_sifr, hkey->package.count); status = AE_ERROR; goto end; } @@ -968,6 +969,12 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) return -ENODEV; } + /* + * Some DSDT-s have an of by one bug where the SINF package count is + * one higher then the SQTY reported value, allocate 1 entry extra. + */ + num_sifr++; + pcc = kzalloc(sizeof(struct pcc_acpi), GFP_KERNEL); if (!pcc) { pr_err("Couldn't allocate mem for pcc"); From patchwork Tue Sep 3 08:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13788284 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CB662101B6 for ; Tue, 3 Sep 2024 08:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725352552; cv=none; b=ul9M5UrEFmV3z0ddgOsBqrQZvvKeBn447KPS0xo6GM7jteuOOpKJ3+GBr/drjwjYgiQVhd8WKyZVrIqHJQqtfX0WWjmDCNZLiA1NK94O4OqT25JZnbWizqljVRYUHfQKUbHBhbDDQWgNutD3F1h69P9GCy53pogJefgwXYzJRpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725352552; c=relaxed/simple; bh=BTmfV+dbk20wxIoisLxlFz0NSY9nvNlUKOx9t2uCNm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rnqXnsvc+lYHk9y/uaMDBS54SXi8igTB2zzAa0N3AZXROSsHOS3IbesOTihUwf/vTAJ/G6IvUOIzeCbmptprHUeA+zT9WeT2SLAFE4hbvEnKuNOQyeH8/Aqld3fqGOXgjDIk97ikojRhY0rt7Z84cWxbHLuOGw8xT2wWdMPyuz0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GuRJX8kf; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GuRJX8kf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725352550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=diPdWsAXoVHRe4pdgH8lVXAuNaKBDPC6yKVNGzO0C3U=; b=GuRJX8kf+T/wFZVebIWgauh+GlyCq1lioZbLD5aM7cvvzx67yt08MCOVYOi/pudhN5B9N1 mp1BuhWQbPq8JBzS78ujmikPEIedrmeYtfHgcVhX5M9gj4QTzWbx53u8WJ3NdNMp7Zlk56 FKJnsk8REsAxSGF21AipaSF3zv0x0fg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-06qTNzUmNYKJCQ8oT5OZvw-1; Tue, 03 Sep 2024 04:35:47 -0400 X-MC-Unique: 06qTNzUmNYKJCQ8oT5OZvw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 17C801955BF2; Tue, 3 Sep 2024 08:35:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.239]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5FFF01956048; Tue, 3 Sep 2024 08:35:44 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , James Harmison , platform-driver-x86@vger.kernel.org Subject: [PATCH 3/3] platform/x86: panasonic-laptop: Add support for programmable buttons Date: Tue, 3 Sep 2024 10:35:33 +0200 Message-ID: <20240903083533.9403-3-hdegoede@redhat.com> In-Reply-To: <20240903083533.9403-1-hdegoede@redhat.com> References: <20240903083533.9403-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 From: James Harmison Newer panasonic toughbook models have a number of programmable buttons, add support for these. Tested-by: James Harmison Signed-off-by: James Harmison Signed-off-by: Hans de Goede --- drivers/platform/x86/panasonic-laptop.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index 4c9e20e1afe8..2070caa1ea1b 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c @@ -224,6 +224,17 @@ static const struct key_entry panasonic_keymap[] = { { KE_KEY, 8, { KEY_PROG1 } }, /* Change CPU boost */ { KE_KEY, 9, { KEY_BATTERY } }, { KE_KEY, 10, { KEY_SUSPEND } }, + { KE_KEY, 21, { KEY_MACRO1 } }, + { KE_KEY, 22, { KEY_MACRO2 } }, + { KE_KEY, 24, { KEY_MACRO3 } }, + { KE_KEY, 25, { KEY_MACRO4 } }, + { KE_KEY, 34, { KEY_MACRO5 } }, + { KE_KEY, 35, { KEY_MACRO6 } }, + { KE_KEY, 36, { KEY_MACRO7 } }, + { KE_KEY, 37, { KEY_MACRO8 } }, + { KE_KEY, 41, { KEY_MACRO9 } }, + { KE_KEY, 42, { KEY_MACRO10 } }, + { KE_KEY, 43, { KEY_MACRO11 } }, { KE_END, 0 } }; @@ -811,7 +822,7 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc) return; } - key = result & 0xf; + key = result & 0x7f; updown = result & 0x80; /* 0x80 == key down; 0x00 = key up */ /* hack: some firmware sends no key down for sleep / hibernate */