net: ti: icss-iep: fix device and OF node leaks at probe
Make sure to drop the references to the IEP OF node and device taken by
of_parse_phandle() and of_find_device_by_node() when looking up IEP
devices during probe.
Drop the bogus additional reference taken on successful lookup so that
the device is released correctly by icss_iep_put().
Fixes: c1e0230eeaab ("net: ti: icss-iep: Add IEP driver")
Cc: stable@vger.kernel.org # 6.6
Cc: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250725171213.880-6-johan@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
3e13274ca8
commit
e05c54974a
@ -685,11 +685,17 @@ struct icss_iep *icss_iep_get_idx(struct device_node *np, int idx)
|
||||
struct platform_device *pdev;
|
||||
struct device_node *iep_np;
|
||||
struct icss_iep *iep;
|
||||
int ret;
|
||||
|
||||
iep_np = of_parse_phandle(np, "ti,iep", idx);
|
||||
if (!iep_np || !of_device_is_available(iep_np))
|
||||
if (!iep_np)
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
if (!of_device_is_available(iep_np)) {
|
||||
of_node_put(iep_np);
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
pdev = of_find_device_by_node(iep_np);
|
||||
of_node_put(iep_np);
|
||||
|
||||
@ -698,21 +704,28 @@ struct icss_iep *icss_iep_get_idx(struct device_node *np, int idx)
|
||||
return ERR_PTR(-EPROBE_DEFER);
|
||||
|
||||
iep = platform_get_drvdata(pdev);
|
||||
if (!iep)
|
||||
return ERR_PTR(-EPROBE_DEFER);
|
||||
if (!iep) {
|
||||
ret = -EPROBE_DEFER;
|
||||
goto err_put_pdev;
|
||||
}
|
||||
|
||||
device_lock(iep->dev);
|
||||
if (iep->client_np) {
|
||||
device_unlock(iep->dev);
|
||||
dev_err(iep->dev, "IEP is already acquired by %s",
|
||||
iep->client_np->name);
|
||||
return ERR_PTR(-EBUSY);
|
||||
ret = -EBUSY;
|
||||
goto err_put_pdev;
|
||||
}
|
||||
iep->client_np = np;
|
||||
device_unlock(iep->dev);
|
||||
get_device(iep->dev);
|
||||
|
||||
return iep;
|
||||
|
||||
err_put_pdev:
|
||||
put_device(&pdev->dev);
|
||||
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(icss_iep_get_idx);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user