From: Qian Cai <quic_qiancai@quicinc.com>
To: Mario Limonciello <mario.limonciello@amd.com>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
<linux-acpi@vger.kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
<Xiaomeng.Hou@amd.com>, <Aaron.Liu@amd.com>, <Ray.Huang@amd.com>,
<hdegoede@redhat.com>
Subject: Re: [PATCH v4 2/3] ACPI: bus: Allow negotiating OSC capabilities
Date: Tue, 8 Mar 2022 16:51:50 -0500 [thread overview]
Message-ID: <YifP9vKoGzyZyRJB@qian> (raw)
In-Reply-To: <20220301124908.1931221-2-mario.limonciello@amd.com>
On Tue, Mar 01, 2022 at 06:49:07AM -0600, Mario Limonciello wrote:
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 07f604832fd6..302619ad9d31 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -184,6 +184,18 @@ static void acpi_print_osc_error(acpi_handle handle,
> pr_debug("\n");
> }
>
> +/**
> + * acpi_run_osc - Evaluate the _OSC method for a given ACPI handle
> + * @handle: ACPI handle containing _OSC to evaluate
> + * @context: A structure specifying UUID, revision, and buffer for data
> + *
> + * Used for negotiating with firmware the capabilities that will be used
> + * by the OSPM. Although the return type is acpi_status, the ACPI_SUCCESS
> + * macro can not be used to determine whether to free the buffer of
> + * returned data.
> + *
> + * The buffer must be freed when this function returns AE_OK or AE_SUPPORT.
> + */
> acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
> {
> acpi_status status;
> @@ -243,16 +255,19 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
> acpi_print_osc_error(handle, context,
> "_OSC invalid revision");
> if (errors & OSC_CAPABILITIES_MASK_ERROR) {
> + acpi_print_osc_error(handle, context, "_OSC capabilities masked");
> if (((u32 *)context->cap.pointer)[OSC_QUERY_DWORD]
> - & OSC_QUERY_ENABLE)
> - goto out_success;
> - status = AE_SUPPORT;
> - goto out_kfree;
> + & OSC_QUERY_ENABLE) {
> + status = AE_SUPPORT;
> + goto out_masked;
> + }
> }
> status = AE_ERROR;
> goto out_kfree;
> }
> -out_success:
> +
> + status = AE_OK;
> +out_masked:
> context->ret.length = out_obj->buffer.length;
> context->ret.pointer = kmemdup(out_obj->buffer.pointer,
> context->ret.length, GFP_KERNEL);
> @@ -260,7 +275,6 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
> status = AE_NO_MEMORY;
> goto out_kfree;
> }
> - status = AE_OK;
>
> out_kfree:
> kfree(output.pointer);
Do we forget to free "context.ret.pointer" in acpi_pci_run_osc() as well
when acpi_run_osc() starts to return AE_SUPPORT? I saw memory leaks on the
latest linux-next which include this series.
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff07ff968c6e80 (size 128):
comm "swapper/0", pid 1, jiffies 4294894996 (age 1785.652s)
hex dump (first 32 bytes):
11 00 00 00 1f 01 00 00 18 00 00 00 6b 6b 6b 6b ............kkkk
6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
backtrace:
[<ffffad5bd9d79adc>] __kmalloc_track_caller
[<ffffad5bd9c439f4>] kmemdup
[<ffffad5bda97c710>] acpi_run_osc
acpi_run_osc at drivers/acpi/bus.c:272
[<ffffad5bdc52f8a8>] acpi_pci_run_osc
acpi_pci_run_osc at drivers/acpi/pci_root.c:184
[<ffffad5bdc52fe30>] negotiate_os_control.constprop.0
acpi_pci_query_osc at drivers/acpi/pci_root.c:205
(inlined by) acpi_pci_osc_control_set at drivers/acpi/pci_root.c:353
(inlined by) negotiate_os_control at drivers/acpi/pci_root.c:482
[<ffffad5bda995748>] acpi_pci_root_add
[<ffffad5bda982558>] acpi_bus_attach
[<ffffad5bda9823c8>] acpi_bus_attach
[<ffffad5bda9823c8>] acpi_bus_attach
[<ffffad5bda98808c>] acpi_bus_scan
[<ffffad5bdd9624a0>] acpi_scan_init
[<ffffad5bdd961e74>] acpi_init
[<ffffad5bd9595438>] do_one_initcall
[<ffffad5bdd90201c>] kernel_init_freeable
[<ffffad5bdc5684e0>] kernel_init
[<ffffad5bd959841c>] ret_from_fork
next prev parent reply other threads:[~2022-03-08 21:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 12:49 [PATCH v4 1/3] ACPI: APEI: Adjust for acpi_run_osc logic changes Mario Limonciello
2022-03-01 12:49 ` [PATCH v4 2/3] ACPI: bus: Allow negotiating OSC capabilities Mario Limonciello
2022-03-01 13:07 ` Mika Westerberg
2022-03-08 21:51 ` Qian Cai [this message]
2022-03-01 12:49 ` [PATCH v4 3/3] ACPI: bus: For platform OSC negotiate capabilities Mario Limonciello
2022-03-01 13:12 ` Mika Westerberg
2022-03-02 20:09 ` [PATCH v4 1/3] ACPI: APEI: Adjust for acpi_run_osc logic changes Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YifP9vKoGzyZyRJB@qian \
--to=quic_qiancai@quicinc.com \
--cc=Aaron.Liu@amd.com \
--cc=Ray.Huang@amd.com \
--cc=Xiaomeng.Hou@amd.com \
--cc=hdegoede@redhat.com \
--cc=linux-acpi@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mika.westerberg@linux.intel.com \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox