mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-17 09:41:09 +02:00
net: mvneta: bm: fix device reference leak on failed lookup
Make sure to drop the reference taken to the buffer manager device when attempting to look up its driver data before the driver has been bound. Note that holding a reference to a device does not prevent its driver data from going away. Cc: stable+noautosel@kernel.org # untested fix to unlikely error path Cc: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com> Link: https://patch.msgid.link/20260709082713.829446-1-johan@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
6deab902b4
commit
ede0f99cef
@@ -397,9 +397,20 @@ static void mvneta_bm_put_sram(struct mvneta_bm *priv)
|
||||
|
||||
struct mvneta_bm *mvneta_bm_get(struct device_node *node)
|
||||
{
|
||||
struct platform_device *pdev = of_find_device_by_node(node);
|
||||
struct platform_device *pdev;
|
||||
struct mvneta_bm *priv;
|
||||
|
||||
return pdev ? platform_get_drvdata(pdev) : NULL;
|
||||
pdev = of_find_device_by_node(node);
|
||||
if (!pdev)
|
||||
return NULL;
|
||||
|
||||
priv = platform_get_drvdata(pdev);
|
||||
if (!priv) {
|
||||
platform_device_put(pdev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return priv;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mvneta_bm_get);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user