drm/imx/tve: fix probe device leak
Subsystems (5)
PATCH 1/1 drm/imx/tve: fix probe device leak
Make sure to drop the reference taken to the DDC device during probe on probe failure (e.g. probe deferral) and on driver unbind.
--- drivers/gpu/drm/imx/ipuv3/imx-tve.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/imx/ipuv3/imx-tve.c +12 -0
@@ -525,6 +525,13 @@ static const struct component_ops imx_tve_ops = { .bind = imx_tve_bind, }; +static void imx_tve_put_device (void *_dev) +{ +struct device *dev = _dev; + +put_device (dev); +} +static int imx_tve_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)if (ddc_node) { tve->ddc =of_find_i2c_adapter_by_node (ddc_node);of_node_put (ddc_node); + + ret =devm_add_action_or_reset (dev, imx_tve_put_device, + &tve->ddc->dev); +if (ret) +return ret; } tve->mode =of_get_tve_mode (np);
Signature · 1 line
2.49.1
Quoted 7 lines · Johan Hovold
Make sure to drop the reference taken to the DDC device during probe on probe failure (e.g. probe deferral) and on driver unbind.
Fixes fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")Cc [email protected] # 3.10Cc Philipp Zabel <[email protected]>Signed-off-by Johan Hovold <[email protected]>
Quoted 37 lines
--- drivers/gpu/drm/imx/ipuv3/imx-tve.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/imx/ipuv3/imx-tve.c +12
-1@@ -525,6 +525,13 @@ static const struct component_ops imx_tve_ops = { .bind = imx_tve_bind, }; +static void imx_tve_put_device (void *_dev) +{ +struct device *dev = _dev; + +put_device (dev); +} +static int imx_tve_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)if (ddc_node) { tve->ddc =of_find_i2c_adapter_by_node (ddc_node);of_node_put (ddc_node); + + ret =devm_add_action_or_reset (dev, imx_tve_put_device, + &tve->ddc->dev); +if (ret) +return ret; } tve->mode =of_get_tve_mode (np); --2.49.1
Quoted 8 lines · Johan Hovold
Make sure to drop the reference taken to the DDC device during probe on probe failure (e.g. probe deferral) and on driver unbind.
Fixes fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")Cc [email protected] # 3.10Cc Philipp Zabel <[email protected]>Signed-off-by Johan Hovold <[email protected]>---
Can this one be picked up for 6.19?
Johan
Philipp Zabel
maintainerQuoted 30 lines · Johan Hovold
Make sure to drop the reference taken to the DDC device during probe on probe failure (e.g. probe deferral) and on driver unbind.
Fixes fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")Cc [email protected] # 3.10Cc Philipp Zabel <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/gpu/drm/imx/ipuv3/imx-tve.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/gpu/drm/imx/ipuv3/imx-tve.c +7
-0@@ -525,6 +525,13 @@ static const struct component_ops imx_tve_ops = { .bind = imx_tve_bind, }; +static void imx_tve_put_device (void *_dev) +{ +struct device *dev = _dev; + +put_device (dev); +} +static int imx_tve_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
drivers/gpu/drm/imx/ipuv3/imx-tve.c static int imx_tve_probe(struct platform_device *pdev) · line 558
Quoted 6 lines
drivers/gpu/drm/imx/ipuv3/imx-tve.c +3
-0@@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)if (ddc_node) { tve->ddc =of_find_i2c_adapter_by_node (ddc_node);of_node_put (ddc_node); + + ret =devm_add_action_or_reset (dev, imx_tve_put_device, + &tve->ddc->dev);
I think this needs to be wrapped in "if (tve->ddc) { }", of_find_i2c_adapter_by_node() can return NULL.
regards
Philipp
Quoted 15 lines · Philipp Zabel
drivers/gpu/drm/imx/ipuv3/imx-tve.c static int imx_tve_probe(struct platform_device *pdev) · line 558
Quoted 10 lines · Johan Hovold
static int
imx_tve_probe(struct platform_device *pdev){drivers/gpu/drm/imx/ipuv3/imx-tve.c +3
-0struct device *dev = &pdev->dev;@@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)if (ddc_node) { tve->ddc =of_find_i2c_adapter_by_node (ddc_node);of_node_put (ddc_node); + + ret =devm_add_action_or_reset (dev, imx_tve_put_device, + &tve->ddc->dev);I think this needs to be wrapped in "if (
tve->ddc) { }",of_find_i2c_adapter_by_node()can return NULL.
Indeed, thanks for catching that. Just sent a v2.
Johan