Search Linux Wireless

Re: [PATCHv3 wireless-next 5/7] wifi: rt2x00: soc: modernize probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 11, 2025 at 7:01 AM Alexander Savchenko
<oleksandr.savchenko.dn@xxxxxxxxxxxxxx> 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





[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux