[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKxU2N9bjn5ybyTpk9Cc4B_GcLYdbEwPtzoxQkuEKH=MeTi-dQ@mail.gmail.com>
Date: Fri, 11 Jul 2025 13:33:27 -0700
From: Rosen Penev <rosenp@...il.com>
To: Alexander Savchenko <oleksandr.savchenko.dn@...renesas.com>
Cc: angelogioacchino.delregno@...labora.com, conor+dt@...nel.org,
devicetree@...r.kernel.org, johannes@...solutions.net, krzk+dt@...nel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mediatek@...ts.infradead.org, linux-mips@...r.kernel.org,
linux-wireless@...r.kernel.org, matthias.bgg@...il.com, robh@...nel.org,
stf_xl@...pl, tsbogend@...ha.franken.de
Subject: Re: [PATCHv3 wireless-next 5/7] wifi: rt2x00: soc: modernize probe
On Fri, Jul 11, 2025 at 7:01 AM Alexander Savchenko
<oleksandr.savchenko.dn@...renesas.com> wrote:
>
> Hi Rosen,
>
> looks like here are memory leaks in the patch, PSB.
>
> > + eeprom = devm_kzalloc(&pdev->dev, ops->eeprom_size, GFP_KERNEL);
> > + if (!eeprom)
> > + return -ENOMEM;
> > +
> > + rf = devm_kzalloc(&pdev->dev, ops->rf_size, GFP_KERNEL);
> > + if (!rf)
> Here driver must freed eeprom memory resource.
> > + return -ENOMEM;
> > +
> > + hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
> > + if (!hw)
> Here driver must freed rf and eeprom resources.
> > + return dev_err_probe(&pdev->dev, -ENOMEM, "Failed to allocate hardware");
> > +
> > + platform_set_drvdata(pdev, hw);
> > +
> > + rt2x00dev = hw->priv;
> > + rt2x00dev->dev = &pdev->dev;
> > + rt2x00dev->ops = ops;
> > + rt2x00dev->hw = hw;
> > + rt2x00dev->irq = irq;
> > + rt2x00dev->clk = clk;
> > + rt2x00dev->eeprom = eeprom;
> > + rt2x00dev->rf = rf;
> > + rt2x00dev->name = pdev->dev.driver->name;
> > + rt2x00dev->csr.base = mem;
> > +
> > + rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
> > +
> > + retval = rt2x00lib_probe_dev(rt2x00dev);
> > + if (retval)
> > + goto exit_free_device;
> > +
> > + return 0;
> > +
> > +exit_free_device:
> > + ieee80211_free_hw(hw);
> > +
> Here driver must freed rf and eeprom resources.
> > + return retval;
> > +}
>
> Also need to check the rest of allocated resources: mem, irq, clk.
The point of devm is to not have to...
>
> BR,
> Alexander
Powered by blists - more mailing lists