Message ID | Yueor88I/DkVSOtL@kili |
---|---|
State | Accepted |
Commit | 88ab1dde792aa6a3902e2a30929e00acc99d351a |
Headers | show |
Series | [1/3] cxl/region: uninitialized variable in alloc_hpa() | expand |
Dan Carpenter wrote: > This should check "p->res" instead of "res" (which is uninitialized). > > Fixes: 23a22cd1c98b ("cxl/region: Allocate HPA capacity to regions") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > --- > drivers/cxl/core/region.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index dc71ec457608..c80932bca667 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -454,7 +454,7 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) > lockdep_assert_held_write(&cxl_region_rwsem); > > /* Nothing to do... */ > - if (p->res && resource_size(res) == size) > + if (p->res && resource_size(p->res) == size) Yup, looks good. Surprised this was not caught by my local compiler, or any of the compile-test robots.
On Mon, Aug 01, 2022 at 12:07:14PM -0700, Dan Williams wrote: > Dan Carpenter wrote: > > This should check "p->res" instead of "res" (which is uninitialized). > > > > Fixes: 23a22cd1c98b ("cxl/region: Allocate HPA capacity to regions") > > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > --- > > drivers/cxl/core/region.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > > index dc71ec457608..c80932bca667 100644 > > --- a/drivers/cxl/core/region.c > > +++ b/drivers/cxl/core/region.c > > @@ -454,7 +454,7 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) > > lockdep_assert_held_write(&cxl_region_rwsem); > > > > /* Nothing to do... */ > > - if (p->res && resource_size(res) == size) > > + if (p->res && resource_size(p->res) == size) > > Yup, looks good. Surprised this was not caught by my local compiler, or > any of the compile-test robots. Yeah. It's weird. We've disabled GCC uninitialized warnings which made me introduce a bug last week... But normally the Clang people and the kbuild bots fix the bugs before I do. regards, dan carpenter
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index dc71ec457608..c80932bca667 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -454,7 +454,7 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size) lockdep_assert_held_write(&cxl_region_rwsem); /* Nothing to do... */ - if (p->res && resource_size(res) == size) + if (p->res && resource_size(p->res) == size) return 0; /* To change size the old size must be freed first */
This should check "p->res" instead of "res" (which is uninitialized). Fixes: 23a22cd1c98b ("cxl/region: Allocate HPA capacity to regions") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- drivers/cxl/core/region.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)