Linux Power Management development
 help / color / mirror / Atom feed
From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Kang Chen <k.chen@smail.nju.edu.cn>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	 Lukasz Luba <lukasz.luba@arm.com>,
	Kaushlendra Kumar <kaushlendra.kumar@intel.com>,
	Pengpeng Hou	 <pengpeng@iscas.ac.cn>,
	Matthew Garrett <mjg59@google.com>,
		linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thermal: int340x: reject changing ODVP package sizes
Date: Tue, 03 Nov 2026 09:48:52 -0800	[thread overview]
Message-ID: <ff11511f777d1d585ea17cd36e51fc461cc4c928.camel@linux.intel.com> (raw)
In-Reply-To: <20261103114106.74290-1-k.chen@smail.nju.edu.cn>

On Tue, 2026-11-03 at 19:41 +0800, Kang Chen wrote:
> evaluate_odvp() sizes priv->odvp from the package count returned by
> the
> first ODVP evaluation, but it never compares that cached size with
> the
> count of a later evaluation.  The function runs at probe time, on
> INT3400_ODVP_CHANGED notifications, and on thermal mode changes, so a
> firmware that answers with a larger package after the first call
> makes
> the fill loop write past the cached allocation.
> 

This is not in practice but fine.

> Ignore packages whose count differs from the cached one, and reject
> counts that do not fit in the int that stores priv->odvp_count.  Also
> reject a missing ODVP object instead of dereferencing a NULL pointer
> when the method returns no value.
> 
Here three potential changes are clubbed together, why not split?


> Fixes: 006f006f1e5c ("thermal/int340x_thermal: Export OEM vendor
> variables")
> Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
> ---
>  .../intel/int340x_thermal/int3400_thermal.c    | 18
> +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> index 5d70301d4a3d..eb899f90970e 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> @@ -377,12 +377,25 @@ static int evaluate_odvp(struct
> int3400_thermal_priv *priv)
>  	}
>  
>  	obj = odvp.pointer;
> -	if (obj->type != ACPI_TYPE_PACKAGE) {
> +	if (!obj || obj->type != ACPI_TYPE_PACKAGE) {
>  		ret = -EINVAL;
>  		goto out_err;
>  	}
>  
> +	if (priv->odvp && priv->odvp_count != obj->package.count) {
> +		dev_warn_once(&priv->pdev->dev,
> +			      "ODVP count changed from %d to %u,
> ignoring\n",
> +			      priv->odvp_count, obj->package.count);
> +		ret = 0;
> +		goto out_free;
> +	}
> +
>  	if (priv->odvp == NULL) {
> +		if (obj->package.count > INT_MAX) {
> +			ret = -EINVAL;
> +			goto out_err;
> +		}
> +
>  		priv->odvp_count = obj->package.count;
>  		priv->odvp = kmalloc_objs(int, priv->odvp_count);
>  		if (!priv->odvp) {
> @@ -429,6 +442,9 @@ static int evaluate_odvp(struct
> int3400_thermal_priv *priv)
>  	kfree(obj);
>  	return 0;
>  
> +out_free:
> +	kfree(obj);
> +	return ret;

Instead of adding another return if you move out_free later, like
below.

>  out_err:
>  	cleanup_odvp(priv);

out_free:

>  	kfree(obj);

Thanks,
Srinivas

      reply	other threads:[~2026-11-03 17:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 11:41 [PATCH] thermal: int340x: reject changing ODVP package sizes Kang Chen
2026-11-03 17:48 ` srinivas pandruvada [this message]

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=ff11511f777d1d585ea17cd36e51fc461cc4c928.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=k.chen@smail.nju.edu.cn \
    --cc=kaushlendra.kumar@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=mjg59@google.com \
    --cc=pengpeng@iscas.ac.cn \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    /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