From: Jani Nikula <jani.nikula@linux.intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>, Jim Qu <Jim.Qu@amd.com>
Cc: Lukas Wunner <lukas@wunner.de>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Takashi Iwai <tiwai@suse.de>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, Su Hui <suhui@nfschina.com>
Subject: Re: [PATCH] vgaswitcheroo: Fix error checking in vga_switcheroo_register_audio_client()
Date: Wed, 19 Feb 2025 17:17:56 +0200 [thread overview]
Message-ID: <87zfiim09n.fsf@intel.com> (raw)
In-Reply-To: <ae24cd32-1e78-4656-b983-051ed22d86b9@stanley.mountain>
On Wed, 19 Feb 2025, Dan Carpenter <dan.carpenter@linaro.org> wrote:
> The "id" variable is an enum and in this context it's treated as an
> unsigned int so the error handling can never trigger.
When would that be true with GCC?
BR,
Jani.
> The
> ->get_client_id() functions do not currently return any errors but
> I imagine that if they did, then the intention was to return
> VGA_SWITCHEROO_UNKNOWN_ID on error. Let's check for both negatives
> and UNKNOWN_ID so we'll catch it either way.
>
> Reported-by: Su Hui <suhui@nfschina.com>
> Closes: https://lore.kernel.org/all/20231026021056.850680-1-suhui@nfschina.com/
> Fixes: 4aaf448fa975 ("vga_switcheroo: set audio client id according to bound GPU id")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/gpu/vga/vga_switcheroo.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
> index 18f2c92beff8..216fb208eb31 100644
> --- a/drivers/gpu/vga/vga_switcheroo.c
> +++ b/drivers/gpu/vga/vga_switcheroo.c
> @@ -375,7 +375,7 @@ int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
> mutex_lock(&vgasr_mutex);
> if (vgasr_priv.active) {
> id = vgasr_priv.handler->get_client_id(vga_dev);
> - if (id < 0) {
> + if ((int)id < 0 || id == VGA_SWITCHEROO_UNKNOWN_ID) {
> mutex_unlock(&vgasr_mutex);
> return -EINVAL;
> }
--
Jani Nikula, Intel
next prev parent reply other threads:[~2025-02-19 15:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 13:49 [PATCH] vgaswitcheroo: Fix error checking in vga_switcheroo_register_audio_client() Dan Carpenter
2025-02-19 15:17 ` Jani Nikula [this message]
2025-02-19 16:04 ` Dan Carpenter
2025-02-19 18:54 ` Jani Nikula
2025-02-24 13:14 ` Jani Nikula
2025-02-24 19:26 ` Dan Carpenter
2025-02-25 9:10 ` Jani Nikula
2025-02-25 9:36 ` Takashi Iwai
2025-02-25 11:56 ` Dan Carpenter
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=87zfiim09n.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=Jim.Qu@amd.com \
--cc=airlied@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=suhui@nfschina.com \
--cc=tiwai@suse.de \
--cc=tzimmermann@suse.de \
/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.