From: Greg Kroah-Hartman Date: Tue, 16 Jun 2020 12:21:03 +0000 (+0200) Subject: 5.7-stable patches X-Git-Tag: v5.4.47~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4886dd0dc05ac19c1085ab4955e294849bc27e52;p=thirdparty%2Fkernel%2Fstable-queue.git 5.7-stable patches added patches: platform-x86-sony-laptop-snc-calls-should-handle-buffer-types.patch --- diff --git a/queue-5.7/platform-x86-sony-laptop-snc-calls-should-handle-buffer-types.patch b/queue-5.7/platform-x86-sony-laptop-snc-calls-should-handle-buffer-types.patch new file mode 100644 index 00000000000..019895a9f91 --- /dev/null +++ b/queue-5.7/platform-x86-sony-laptop-snc-calls-should-handle-buffer-types.patch @@ -0,0 +1,114 @@ +From 47828d22539f76c8c9dcf2a55f18ea3a8039d8ef Mon Sep 17 00:00:00 2001 +From: Mattia Dongili +Date: Fri, 8 May 2020 09:14:04 +0900 +Subject: platform/x86: sony-laptop: SNC calls should handle BUFFER types + +From: Mattia Dongili + +commit 47828d22539f76c8c9dcf2a55f18ea3a8039d8ef upstream. + +After commit 6d232b29cfce ("ACPICA: Dispatcher: always generate buffer +objects for ASL create_field() operator") ACPICA creates buffers even +when new fields are small enough to fit into an integer. +Many SNC calls counted on the old behaviour. +Since sony-laptop already handles the INTEGER/BUFFER case in +sony_nc_buffer_call, switch sony_nc_int_call to use its more generic +function instead. + +Fixes: 6d232b29cfce ("ACPICA: Dispatcher: always generate buffer objects for ASL create_field() operator") +Reported-by: Dominik Mierzejewski +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207491 +Reported-by: William Bader +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1830150 +Signed-off-by: Mattia Dongili +Signed-off-by: Andy Shevchenko +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/platform/x86/sony-laptop.c | 53 ++++++++++++++++--------------------- + 1 file changed, 23 insertions(+), 30 deletions(-) + +--- a/drivers/platform/x86/sony-laptop.c ++++ b/drivers/platform/x86/sony-laptop.c +@@ -757,33 +757,6 @@ static union acpi_object *__call_snc_met + return result; + } + +-static int sony_nc_int_call(acpi_handle handle, char *name, int *value, +- int *result) +-{ +- union acpi_object *object = NULL; +- if (value) { +- u64 v = *value; +- object = __call_snc_method(handle, name, &v); +- } else +- object = __call_snc_method(handle, name, NULL); +- +- if (!object) +- return -EINVAL; +- +- if (object->type != ACPI_TYPE_INTEGER) { +- pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n", +- ACPI_TYPE_INTEGER, object->type); +- kfree(object); +- return -EINVAL; +- } +- +- if (result) +- *result = object->integer.value; +- +- kfree(object); +- return 0; +-} +- + #define MIN(a, b) (a > b ? b : a) + static int sony_nc_buffer_call(acpi_handle handle, char *name, u64 *value, + void *buffer, size_t buflen) +@@ -795,17 +768,20 @@ static int sony_nc_buffer_call(acpi_hand + if (!object) + return -EINVAL; + +- if (object->type == ACPI_TYPE_BUFFER) { ++ if (!buffer) { ++ /* do nothing */ ++ } else if (object->type == ACPI_TYPE_BUFFER) { + len = MIN(buflen, object->buffer.length); ++ memset(buffer, 0, buflen); + memcpy(buffer, object->buffer.pointer, len); + + } else if (object->type == ACPI_TYPE_INTEGER) { + len = MIN(buflen, sizeof(object->integer.value)); ++ memset(buffer, 0, buflen); + memcpy(buffer, &object->integer.value, len); + + } else { +- pr_warn("Invalid acpi_object: expected 0x%x got 0x%x\n", +- ACPI_TYPE_BUFFER, object->type); ++ pr_warn("Unexpected acpi_object: 0x%x\n", object->type); + ret = -EINVAL; + } + +@@ -813,6 +789,23 @@ static int sony_nc_buffer_call(acpi_hand + return ret; + } + ++static int sony_nc_int_call(acpi_handle handle, char *name, int *value, int ++ *result) ++{ ++ int ret; ++ ++ if (value) { ++ u64 v = *value; ++ ++ ret = sony_nc_buffer_call(handle, name, &v, result, ++ sizeof(*result)); ++ } else { ++ ret = sony_nc_buffer_call(handle, name, NULL, result, ++ sizeof(*result)); ++ } ++ return ret; ++} ++ + struct sony_nc_handles { + u16 cap[0x10]; + struct device_attribute devattr; diff --git a/queue-5.7/series b/queue-5.7/series index e966973c4a3..091cfb9457c 100644 --- a/queue-5.7/series +++ b/queue-5.7/series @@ -157,3 +157,4 @@ mmc-sdio-fix-potential-null-pointer-error-in-mmc_sdio_init_card.patch mmc-sdio-fix-several-potential-memory-leaks-in-mmc_sdio_init_card.patch block-floppy-fix-contended-case-in-floppy_queue_rq.patch xen-pvcalls-back-test-for-errors-when-calling-backend_connect.patch +platform-x86-sony-laptop-snc-calls-should-handle-buffer-types.patch