lkml.org 
[lkml]   [2024]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH 1/2] cxl/region: Fix potential invalid pointer dereference
    From
    I would usually expect a corresponding cover letter for patch series.


    > construct_region() could return a PTR_ERR() which cannot be derefernced.

    I hope that a typo will be avoided in the last word of this sentence.


    > Moving the dereference behind the error checking to make sure the
    > pointer is valid.

    Please choose an imperative wording for an improved change description.
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc5#n94



    > +++ b/drivers/cxl/core/region.c
    > @@ -3086,10 +3086,9 @@ int cxl_add_to_region(struct cxl_port *root, struct cxl_endpoint_decoder *cxled)
    > mutex_lock(&cxlrd->range_lock);
    > region_dev = device_find_child(&cxlrd->cxlsd.cxld.dev, hpa,
    > match_region_by_range);
    > - if (!region_dev) {
    > + if (!region_dev)
    > cxlr = construct_region(cxlrd, cxled);
    > - region_dev = &cxlr->dev;
    > - } else
    > + else
    > cxlr = to_cxl_region(region_dev);
    > mutex_unlock(&cxlrd->range_lock);

    I suggest to simplify such source code by using a conditional operator expression.

    Regards,
    Markus

    \
     
     \ /
      Last update: 2024-05-27 18:07    [W:3.084 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site