lkml.org 
[lkml]   [2019]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] dmaengine: imx-sdma: fix use-after-free on probe error path
    On 24-06-19, 10:07, Sven Van Asbroeck wrote:

    Quoting orignal patch for better context:

    > + if (pdata) {
    > + ret = sdma_get_firmware(sdma, pdata->fw_name);
    > + if (ret)
    > + dev_warn(&pdev->dev, "failed to get firmware from platform data\n");
    > + } else {
    > + /*
    > + * Because that device tree does not encode ROM script address,
    > + * the RAM script in firmware is mandatory for device tree
    > + * probe, otherwise it fails.
    > + */
    > + ret = of_property_read_string(np, "fsl,sdma-ram-script-name",
    > + &fw_name);
    > + if (ret)
    > + dev_warn(&pdev->dev, "failed to get firmware name\n");
    > + else {
    > + ret = sdma_get_firmware(sdma, fw_name);
    > + if (ret)
    > + dev_warn(&pdev->dev, "failed to get firmware from device tree\n");
    > + }
    > + }
    > +

    On 05-07-19, 08:26, Sven Van Asbroeck wrote:
    > Hi Vinod,
    >
    > On Fri, Jul 5, 2019 at 3:32 AM Vinod Koul <vkoul@kernel.org> wrote:
    > >
    > > > + if (ret)
    > > > + dev_warn(&pdev->dev, "failed to get firmware name\n");
    > >
    > > if should have braces!
    > > Applied after fixing braces!
    >
    > checkpatch.pl output after adding braces:
    >
    > WARNING: braces {} are not necessary for single statement blocks
    > #102: FILE: drivers/dma/imx-sdma.c:2165:
    > + if (ret) {
    > + dev_warn(&pdev->dev, "failed to get firmware from device tree\n");
    > + }

    there is an else here too!

    With the patch the checkpatch warns:

    CHECK: braces {} should be used on all arms of this statement
    #201: FILE: drivers/dma/imx-sdma.c:2161:
    + if (ret)
    [...]
    + else {
    [...]


    Even if the if is a single block and else being multi block, if would
    need matching brances. With the change pushed:

    total: 0 errors, 0 warnings, 0 checks, 60 lines checked


    --
    ~Vinod

    \
     
     \ /
      Last update: 2019-07-05 14:51    [W:3.937 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site