0

In the probe routine of platform drivers, I see the private device structures are being allocated via devm_kzalloc(). Before setting the driver data via platform_set_drvdata() there are error conditions which return without freeing the allocated private device structure. I'm unable find the place where this struct will be freed. Can you please point where does the struct gets freed. Below is example platform driver in Linux kernel source(v5.0), where ep is not freed when pci allocation fails.

static int __init exynos_pcie_probe(struct platform_device *pdev)
{
    struct device *dev = &pdev->dev;
    struct dw_pcie *pci;
    struct exynos_pcie *ep;
    struct device_node *np = dev->of_node;
    int ret;

    ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL);
    if (!ep)
            return -ENOMEM;
    pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
    if (!pci)
       return -ENOMEM;
    ...
    ...
}
foo_l
  • 591
  • 2
  • 10
  • 28
  • 3
    https://stackoverflow.com/questions/12256986/what-is-the-difference-between-devm-kzalloc-and-kzalloc-in-linux-driver-prog all answers is here. – Nick S Mar 12 '19 at 17:39
  • @NickS, you may flag this question as duplicate. – 0andriy Mar 13 '19 at 06:52

0 Answers0