From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: <mallesh.koujalagi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <lucas.demarchi@intel.com>,
<anshuman.gupta@intel.com>, <badal.nilawar@intel.com>,
<riana.tauro@intel.com>, <karthik.poosa@intel.com>,
<sk.anirban@intel.com>, <raag.jadav@intel.com>
Subject: Re: [PATCH] drm/xe/xe_late_bind_fw: Initialize uval variable in xe_late_bind_fw_num_fans()
Date: Wed, 1 Oct 2025 11:29:41 -0400 [thread overview]
Message-ID: <aN1I5dVl6kQeRnjZ@intel.com> (raw)
In-Reply-To: <20251001010933.3179753-1-mallesh.koujalagi@intel.com>
On Wed, Oct 01, 2025 at 06:39:33AM +0530, mallesh.koujalagi@intel.com wrote:
> From: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
>
> Initialize the uval variable to 0 in xe_late_bind_fw_num_fans() to fix
> a potential use of uninitialized variable warning and ensure predictable
> behavior.
>
> The variable is passed by reference to xe_pcode_read() which should
> populate it on success, but initializing it to 0 provides a safe
> default value and follows kernel coding best practices.
>
> v2:
> - uval = 0 which serves as both a safe default and the fallback
> value when the pcode read operation fails.
>
> Fixes: 45832bf9c10f3 ("drm/xe/xe_late_bind_fw: Initialize late binding firmware")
> Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_late_bind_fw.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_late_bind_fw.c b/drivers/gpu/drm/xe/xe_late_bind_fw.c
> index 38f3feb2aecd..46981a6f28ae 100644
> --- a/drivers/gpu/drm/xe/xe_late_bind_fw.c
> +++ b/drivers/gpu/drm/xe/xe_late_bind_fw.c
> @@ -188,13 +188,11 @@ static int xe_late_bind_fw_num_fans(struct xe_late_bind *late_bind)
> {
> struct xe_device *xe = late_bind_to_xe(late_bind);
> struct xe_tile *root_tile = xe_device_get_root_tile(xe);
> - u32 uval;
> + u32 uval = 0;
>
> - if (!xe_pcode_read(root_tile,
> - PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), &uval, NULL))
> - return uval;
> - else
> - return 0;
> + xe_pcode_read(root_tile,
> + PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_NUM_FANS, 0), &uval, NULL);
> + return uval;
I'm afraid both code are wrong.
Although this version is cleaner and not returning garbage, you are still
returning 0 when MMIO operation failed. That propagates 0 and success upwards.
This function should probably return the error and make the uval as pointer-argument,
like the pcode_read.
Then also change the caller of this function to propagate the error upwards
if mmio failed.
> }
>
> void xe_late_bind_wait_for_worker_completion(struct xe_late_bind *late_bind)
> --
> 2.34.1
>
next prev parent reply other threads:[~2025-10-01 15:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 1:09 [PATCH] drm/xe/xe_late_bind_fw: Initialize uval variable in xe_late_bind_fw_num_fans() mallesh.koujalagi
2025-10-01 1:42 ` ✓ CI.KUnit: success for drm/xe/xe_late_bind_fw: Initialize uval variable in xe_late_bind_fw_num_fans() (rev2) Patchwork
2025-10-01 2:35 ` ✓ Xe.CI.BAT: " Patchwork
2025-10-01 4:39 ` ✗ Xe.CI.Full: failure " Patchwork
2025-10-01 15:29 ` Rodrigo Vivi [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-10-02 0:56 [PATCH] drm/xe/xe_late_bind_fw: Initialize uval variable in xe_late_bind_fw_num_fans() mallesh.koujalagi
2025-10-02 14:10 ` Rodrigo Vivi
2025-10-03 11:16 ` Nilawar, Badal
2025-10-03 14:21 ` Rodrigo Vivi
2025-10-01 0:53 mallesh.koujalagi
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=aN1I5dVl6kQeRnjZ@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=lucas.demarchi@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=sk.anirban@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 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.