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;
...
...
}