lkml.org 
[lkml]   [2024]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] cxl/region: Fix potential invalid pointer dereference
On Mon, Apr 29, 2024 at 10:25:35AM +0000, Zhijian Li (Fujitsu) wrote:
> > 3084 mutex_lock(&cxlrd->range_lock);
> > 3085 region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
> > 3086 match_region_by_range);
> > 3087 if (!region_dev) {
> > 3088 cxlr = construct_region(cxlrd, cxled);
> > 3089 region_dev = &cxlr->dev;
> > ^^^^^^^^^^^
> > This is not a dereference, it's just pointer math. In in this case it's
> > the same as saying:
> >
> > region_dev = (void *)cxlr;
>
>
> You are right, a equivalent code could be:
> region_dev = ((char *)cxlr) + offsetof(struct cxl_region, dev);
>
>

Correct. But offsetof() is zero. It's the same math that to_cxl_region()
does.

regards,
dan carpenter


\
 
 \ /
  Last update: 2024-04-29 12:30    [W:0.804 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site