Thread (25 messages) 25 messages, 6 authors, 2025-07-13

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

From: Rosen Penev <hidden>
Date: 2025-07-11 20:33:39
Also in: linux-devicetree, linux-mediatek, linux-mips, linux-wireless, lkml

On Fri, Jul 11, 2025 at 7:01 AM Alexander Savchenko
[off-list ref] wrote:
Hi Rosen,

looks like here are memory leaks in the patch, PSB.
quoted
+     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.
quoted
+             return -ENOMEM;
+
+     hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
+     if (!hw)
Here driver must freed rf and eeprom resources.
quoted
+             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.
quoted
+     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
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help