[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aAZm9eVsEnQvDvrD@gourry-fedora-PF4VCD3F>
Date: Mon, 21 Apr 2025 11:40:37 -0400
From: Gregory Price <gourry@...rry.net>
To: Li Ming <ming.li@...omail.com>
Cc: Purva Yeshi <purvayeshi550@...il.com>, huang.ying.caritas@...il.com,
linux-cxl@...r.kernel.org, linux-kernel@...r.kernel.org,
dave@...olabs.net, jonathan.cameron@...wei.com,
dave.jiang@...el.com, alison.schofield@...el.com,
vishal.l.verma@...el.com, ira.weiny@...el.com,
dan.j.williams@...el.com
Subject: Re: [PATCH] cxl: core: Initialize eiw and eig to fix potential
uninitialized use
On Sun, Apr 20, 2025 at 06:43:37PM +0800, Li Ming wrote:
> On 4/20/2025 4:35 AM, Purva Yeshi wrote:
> > Fix Smatch-detected issue:
> >
> > drivers/cxl/core/region.c:1292 check_interleave_cap()
> > error: uninitialized symbol 'eiw'.
> > drivers/cxl/core/region.c:1297 check_interleave_cap()
> > error: uninitialized symbol 'eig'.
> > drivers/cxl/core/region.c:1299 check_interleave_cap()
> > error: uninitialized symbol 'eig'.
> >
> > Smatch reports possible uninitialized usage of these variables if
> > the helper functions ways_to_eiw() or granularity_to_eig() fail to
> > assign values under certain conditions.
> >
> > Initialize the eiw and eig variables to zero when they are declared
> > in check_interleave_cap() to prevent potential use of uninitialized
> > values.
>
> I also met them during checking cxl drivers code with code inspection tools. But they are not real issues, because both iw and ig are checked before calling check_interleave_cap(). That means check_interleave_cap() will always get a eiw and a eig correctly.
>
> they are checked in cxl_port_setup_targets() in auto-assembly case, otherwise checked in interleave_ways_store() and interleave_guranularity_store().
>
unlikely, but things can change and if we know about this now we should
just fix it to avoid someone tripping over it in the future
~Gregory
Powered by blists - more mailing lists