All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Thorsten Blum <blum@kernel.org>
Cc: Hans de Goede <hansg@kernel.org>,
	Seth Forshee <sforshee@kernel.org>,
	 Matthew Garrett <mjg@redhat.com>,
	platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH] platform/x86: apple-gmux: Fix max_brightness limit check in gmux_probe()
Date: Fri, 20 Nov 2026 16:38:57 +0200 (EET)	[thread overview]
Message-ID: <9fa07231-6bb4-86d5-451f-f5a18d33d967@linux.intel.com> (raw)
In-Reply-To: <20261120142914.825047-2-blum@kernel.org>

On Fri, 20 Nov 2026, Thorsten Blum wrote:

> gmux_read32() returns a u32, but the maximum brightness is stored in the
> signed ->max_brightness field. Large values can thus become negative and
> bypass the GMUX_MAX_BRIGHTNESS check.
> 
> Cast props.max_brightness to u32 for the check so that these values also
> trigger the warning and are capped at GMUX_MAX_BRIGHTNESS.
> 
> Fixes: 917ee75a5916 ("platform/x86: Add driver for Apple gmux device")
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> Found by code inspection; not reproduced on hardware.
> 
>  drivers/platform/x86/apple-gmux.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
> index 9c728ac4e045..4d3a6d2393f7 100644
> --- a/drivers/platform/x86/apple-gmux.c
> +++ b/drivers/platform/x86/apple-gmux.c
> @@ -881,7 +881,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
>  		 * brightness at this value, but print a warning if the hardware
>  		 * reports something higher so that it can be fixed.
>  		 */
> -		if (WARN_ON(props.max_brightness > GMUX_MAX_BRIGHTNESS))
> +		if (WARN_ON((u32)props.max_brightness > GMUX_MAX_BRIGHTNESS))

???

This looks very wrong way to fix the problem (using int as proxy to 
carry it until it's bounds checked).

And why is it using WARN_ON()? Is it an indication of programming error 
that gmux_read32() returns a too large value??

-- 
 i.


  reply	other threads:[~2026-11-20 14:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 14:29 [PATCH] platform/x86: apple-gmux: Fix max_brightness limit check in gmux_probe() Thorsten Blum
2026-11-20 14:38 ` Ilpo Järvinen [this message]
2026-11-20 14:56   ` Thorsten Blum

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=9fa07231-6bb4-86d5-451f-f5a18d33d967@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=blum@kernel.org \
    --cc=hansg@kernel.org \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sforshee@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.