Commit eaf6e69d authored by Wen Yang's avatar Wen Yang Committed by Greg Kroah-Hartman

drm/pl111: fix possible object reference leak

[ Upstream commit bc29d3a6 ]

The call to of_find_matching_node_and_match returns a node pointer with
refcount incremented thus it must be explicitly decremented after the
last usage.

Detected by coccinelle with the following warnings:
drivers/gpu/drm/pl111/pl111_versatile.c:333:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:340:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:346:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:354:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:395:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
drivers/gpu/drm/pl111/pl111_versatile.c:402:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 317, but without a corresponding object release within this function.
Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
Cc: Eric Anholt <eric@anholt.net> (supporter:DRM DRIVER FOR ARM PL111 CLCD)
Cc: David Airlie <airlied@linux.ie> (maintainer:DRM DRIVERS)
Cc: Daniel Vetter <daniel@ffwll.ch> (maintainer:DRM DRIVERS)
Cc: dri-devel@lists.freedesktop.org (open list:DRM DRIVERS)
Cc: linux-kernel@vger.kernel.org (open list)
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1554307455-40361-6-git-send-email-wen.yang99@zte.com.cnSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 34e3da15
...@@ -330,6 +330,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv) ...@@ -330,6 +330,7 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
ret = vexpress_muxfpga_init(); ret = vexpress_muxfpga_init();
if (ret) { if (ret) {
dev_err(dev, "unable to initialize muxfpga driver\n"); dev_err(dev, "unable to initialize muxfpga driver\n");
of_node_put(np);
return ret; return ret;
} }
...@@ -337,17 +338,20 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv) ...@@ -337,17 +338,20 @@ int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv)
pdev = of_find_device_by_node(np); pdev = of_find_device_by_node(np);
if (!pdev) { if (!pdev) {
dev_err(dev, "can't find the sysreg device, deferring\n"); dev_err(dev, "can't find the sysreg device, deferring\n");
of_node_put(np);
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
map = dev_get_drvdata(&pdev->dev); map = dev_get_drvdata(&pdev->dev);
if (!map) { if (!map) {
dev_err(dev, "sysreg has not yet probed\n"); dev_err(dev, "sysreg has not yet probed\n");
platform_device_put(pdev); platform_device_put(pdev);
of_node_put(np);
return -EPROBE_DEFER; return -EPROBE_DEFER;
} }
} else { } else {
map = syscon_node_to_regmap(np); map = syscon_node_to_regmap(np);
} }
of_node_put(np);
if (IS_ERR(map)) { if (IS_ERR(map)) {
dev_err(dev, "no Versatile syscon regmap\n"); dev_err(dev, "no Versatile syscon regmap\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment