drm/vc4: remove all usages of of_node_put()
Subsystems (3)
PATCH 1/1 drm/vc4: remove all usages of of_node_put()
Use the scope-based cleanup feature to clean up 'struct device_node *' when they go out of scope, and remove all instances of of_node_put() within the same scope, to simplify function exit and avoid potential memory leaks.
--- drivers/gpu/drm/vc4/vc4_drv.c | 14 ++++++-------- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +--- drivers/gpu/drm/vc4/vc4_hvs.c | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +6 -8
@@ -289,7 +289,6 @@ static int vc4_drm_bind(struct device *dev)struct rpi_firmware *firmware =NULL ;struct drm_device *drm;struct vc4_dev *vc4; -struct device_node *node;struct drm_crtc *crtc;bool is_vc5;int ret =0 ;
@@ -302,11 +301,10 @@ static int vc4_drm_bind(struct device *dev)else driver = &vc4_drm_driver; - node =of_find_matching_node_and_match (NULL , vc4_dma_range_matches, -NULL ); + struct device_node *node __free(device_node) = +of_find_matching_node_and_match (NULL , vc4_dma_range_matches,NULL );if (node) { ret =of_dma_configure (dev, node, true); -of_node_put (node);if (ret)return ret;
@@ -341,10 +339,10 @@ static int vc4_drm_bind(struct device *dev) goto err; } - node =of_find_compatible_node (NULL ,NULL ,"raspberrypi,bcm2835-firmware" ); -if (node) { - firmware =rpi_firmware_get (node); -of_node_put (node); + struct device_node *np __free(device_node) = +of_find_compatible_node (NULL ,NULL ,"raspberrypi,bcm2835-firmware" ); +if (np) { + firmware =rpi_firmware_get (np);if (!firmware) { ret = -EPROBE_DEFER ;
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -3
@@ -3661,7 +3661,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm =dev_get_drvdata (master);struct vc4_hdmi *vc4_hdmi;struct drm_encoder *encoder; -struct device_node *ddc_node;int ret; vc4_hdmi =drmm_kzalloc (drm,sizeof (*vc4_hdmi),GFP_KERNEL );
@@ -3699,14 +3698,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)if (ret)return ret; - ddc_node =of_parse_phandle (dev->of_node,"ddc" ,0 ); + struct device_node *ddc_node __free(device_node) = of_parse_phandle(dev->of_node, "ddc", 0);if (!ddc_node) {DRM_ERROR ("Failed to find ddc node in device tree\n" );return -ENODEV ; } vc4_hdmi->ddc =of_find_i2c_adapter_by_node (ddc_node); -of_node_put (ddc_node);if (!vc4_hdmi->ddc) {DRM_DEBUG ("Failed to get ddc i2c adapter by node\n" );return -EPROBE_DEFER ;
drivers/gpu/drm/vc4/vc4_hvs.c +1 -3
@@ -845,15 +845,13 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)if (vc4->is_vc5) {struct rpi_firmware *firmware; -struct device_node *node; + struct device_node *node __free(device_node) = rpi_firmware_find_node();unsigned int max_rate; - node =rpi_firmware_find_node ();if (!node)return -EINVAL ; firmware =rpi_firmware_get (node); -of_node_put (node);if (!firmware)return -EPROBE_DEFER ;
Signature · 1 line
2.34.1
Quoted 93 lines · Amer Al Shanawany
Use the scope-based cleanup feature to clean up 'struct
device_node*' when they go out of scope, and remove all instances ofof_node_put()within the same scope, to simplify function exit and avoid potential memory leaks.Suggested-by Julia Lawall <[email protected]>Signed-off-by Amer Al Shanawany <[email protected]>--- drivers/gpu/drm/vc4/vc4_drv.c | 14 ++++++-------- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +--- drivers/gpu/drm/vc4/vc4_hvs.c | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-)drivers/gpu/drm/vc4/vc4_drv.c +6
-8@@ -289,7 +289,6 @@ static int vc4_drm_bind(struct device *dev)struct rpi_firmware *firmware =NULL ;struct drm_device *drm;struct vc4_dev *vc4; -struct device_node *node;struct drm_crtc *crtc;bool is_vc5;int ret =0 ;@@ -302,11 +301,10 @@ static int vc4_drm_bind(struct device *dev)else driver = &vc4_drm_driver; - node =of_find_matching_node_and_match (NULL , vc4_dma_range_matches, -NULL ); + struct device_node *node __free(device_node) = +of_find_matching_node_and_match (NULL , vc4_dma_range_matches,NULL );if (node) { ret =of_dma_configure (dev, node, true); -of_node_put (node);if (ret)return ret;@@ -341,10 +339,10 @@ static int vc4_drm_bind(struct device *dev) goto err; } - node =of_find_compatible_node (NULL ,NULL ,"raspberrypi,bcm2835-firmware" ); -if (node) { - firmware =rpi_firmware_get (node); -of_node_put (node); + struct device_node *np __free(device_node) = +of_find_compatible_node (NULL ,NULL ,"raspberrypi,bcm2835-firmware" ); +if (np) { + firmware =rpi_firmware_get (np);if (!firmware) { ret = -EPROBE_DEFER ;drivers/gpu/drm/vc4/vc4_hdmi.c +1
-3@@ -3661,7 +3661,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)struct drm_device *drm =dev_get_drvdata (master);struct vc4_hdmi *vc4_hdmi;struct drm_encoder *encoder; -struct device_node *ddc_node;int ret; vc4_hdmi =drmm_kzalloc (drm,sizeof (*vc4_hdmi),GFP_KERNEL );@@ -3699,14 +3698,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)if (ret)return ret; - ddc_node =of_parse_phandle (dev->of_node,"ddc" ,0 ); + struct device_node *ddc_node __free(device_node) = of_parse_phandle(dev->of_node, "ddc", 0);if (!ddc_node) {DRM_ERROR ("Failed to find ddc node in device tree\n" );return -ENODEV ; } vc4_hdmi->ddc =of_find_i2c_adapter_by_node (ddc_node); -of_node_put (ddc_node);if (!vc4_hdmi->ddc) {DRM_DEBUG ("Failed to get ddc i2c adapter by node\n" );return -EPROBE_DEFER ;drivers/gpu/drm/vc4/vc4_hvs.c +1
-1@@ -845,15 +845,13 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)if (vc4->is_vc5) {struct rpi_firmware *firmware; -struct device_node *node; + struct device_node *node __free(device_node) = rpi_firmware_find_node();unsigned int max_rate;
drivers/gpu/drm/vc4/vc4_hvs.c static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) · line 857
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_hvs.c +0
-2- node =rpi_firmware_find_node ();if (!node)return -EINVAL ; firmware =rpi_firmware_get (node); -of_node_put (node);if (!firmware)return -EPROBE_DEFER ;
Hi,
This patch is marked as new/archived on patchwork[1], however it didn't receive any feedback, and a similar patch has been already merged [2].
[1]: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/
Thank you
Amer
Quoted 99 lines · Amer Al Shanawany
Quoted 92 lines · Amer Al Shanawany
Use the scope-based cleanup feature to clean up 'struct
device_node*' when they go out of scope, and remove all instances ofof_node_put()within the same scope, to simplify function exit and avoid potential memory leaks.Suggested-by Julia Lawall <[email protected]>Signed-off-by Amer Al Shanawany <[email protected]>---
drivers/gpu/drm/vc4/vc4_drv.c | 14 ++++++--------drivers/gpu/drm/vc4/vc4_hdmi.c| 4 +--- drivers/gpu/drm/vc4/vc4_hvs.c | 4 +---3 files changed, 8 insertions(+), 14 deletions(-)drivers/gpu/drm/vc4/vc4_drv.c +0
-1@@ -289,7 +289,6 @@ static int vc4_drm_bind(struct device *dev) struct rpi_firmware *firmware = NULL; struct drm_device *drm; struct vc4_dev *vc4; - struct device_node *node; struct drm_crtc *crtc; bool is_vc5; int ret = 0;@@ -302,11 +301,10 @@ static int vc4_drm_bind(struct device *dev)else
driver =&vc4_drm_driver;
- node =of_find_matching_node_and_match(NULL, vc4_dma_range_matches, - NULL);
+ structdevice_node*node__free(device_node)=
+of_find_matching_node_and_match(NULL, vc4_dma_range_matches, NULL); if (node) {
ret =of_dma_configure(dev, node, true);
-of_node_put(node);
if (ret)
return ret;drivers/gpu/drm/vc4/vc4_drv.c +4
-3@@ -341,10 +339,10 @@ static int vc4_drm_bind(struct device *dev) goto err; } - node = of_find_compatible_node(NULL, NULL, "raspberrypi,bcm2835-firmware"); - if (node) { - firmware = rpi_firmware_get(node); - of_node_put(node); + struct device_node *np __free(device_node) = + of_find_compatible_node(NULL, NULL, "raspberrypi,bcm2835-firmware"); + if (np) { + firmware = rpi_firmware_get(np); if (!firmware) { ret = -EPROBE_DEFER;drivers/gpu/drm/vc4/vc4_hdmi.c +1
-2@@ -3661,7 +3661,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm = dev_get_drvdata(master); struct vc4_hdmi *vc4_hdmi; struct drm_encoder *encoder; - struct device_node *ddc_node; int ret; vc4_hdmi = drmm_kzalloc(drm, sizeof(*vc4_hdmi), GFP_KERNEL);@@ -3699,14 +3698,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - ddc_node = of_parse_phandle(dev->of_node, "ddc", 0); + struct device_node *ddc_node __free(device_node) = of_parse_phandle(dev->of_node, "ddc", 0); if (!ddc_node) { DRM_ERROR("Failed to find ddc node in device tree\n"); return -ENODEV; } vc4_hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node); - of_node_put(ddc_node); if (!vc4_hdmi->ddc) { DRM_DEBUG("Failed to get ddc i2c adapter by node\n"); return -EPROBE_DEFER;drivers/gpu/drm/vc4/vc4_hvs.c +1
-2@@ -845,15 +845,13 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) if (vc4->is_vc5) { struct rpi_firmware *firmware; - struct device_node *node; + struct device_node *node __free(device_node) = rpi_firmware_find_node(); unsigned int max_rate; - node = rpi_firmware_find_node(); if (!node) return -EINVAL; firmware = rpi_firmware_get(node); - of_node_put(node); if (!firmware) return -EPROBE_DEFER;Quoted 1 line
Hi,
This patch is marked as new/archived on patchwork[1], however it didn't receive any feedback, and a similar patch has been already merged [2].
Quoted 8 lines
[1]: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/
Thank you
Amer
Hello,
Could anyone kindly provide some feedback on this patch?
Thank you
Amer
Quoted 108 lines · Amer Al Shanawany
Quoted 99 lines · Amer Al Shanawany
Quoted 83 lines · Amer Al Shanawany
Use the scope-based cleanup feature to clean up 'struct
device_node*' when they go out of scope, and remove all instances ofof_node_put()within the same scope, to simplify function exit and avoid potential memory leaks.Suggested-by Julia Lawall <[email protected]>Signed-off-by Amer Al Shanawany <[email protected]>--- drivers/gpu/drm/vc4/vc4_drv.c | 14 ++++++-------- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +--- drivers/gpu/drm/vc4/vc4_hvs.c | 4 +--- 3 files changed, 8 insertions(+), 14 deletions(-)drivers/gpu/drm/vc4/vc4_drv.c +6
-6@@ -289,7 +289,6 @@ static int vc4_drm_bind(struct device *dev) struct rpi_firmware *firmware = NULL; struct drm_device *drm; struct vc4_dev *vc4; - struct device_node *node; struct drm_crtc *crtc; bool is_vc5; int ret = 0;@@ -302,11 +301,10 @@ static int vc4_drm_bind(struct device *dev) else driver = &vc4_drm_driver; - node = of_find_matching_node_and_match(NULL, vc4_dma_range_matches, - NULL); + struct device_node *node __free(device_node) = + of_find_matching_node_and_match(NULL, vc4_dma_range_matches, NULL); if (node) { ret = of_dma_configure(dev, node, true); - of_node_put(node); if (ret) return ret;@@ -341,10 +339,10 @@ static int vc4_drm_bind(struct device *dev) goto err; } - node = of_find_compatible_node(NULL, NULL, "raspberrypi,bcm2835-firmware"); - if (node) { - firmware = rpi_firmware_get(node); - of_node_put(node); + struct device_node *np __free(device_node) = + of_find_compatible_node(NULL, NULL, "raspberrypi,bcm2835-firmware"); + if (np) { + firmware = rpi_firmware_get(np); if (!firmware) { ret = -EPROBE_DEFER;drivers/gpu/drm/vc4/vc4_hdmi.c +1
-2@@ -3661,7 +3661,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) struct drm_device *drm = dev_get_drvdata(master); struct vc4_hdmi *vc4_hdmi; struct drm_encoder *encoder; - struct device_node *ddc_node; int ret; vc4_hdmi = drmm_kzalloc(drm, sizeof(*vc4_hdmi), GFP_KERNEL);@@ -3699,14 +3698,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - ddc_node = of_parse_phandle(dev->of_node, "ddc", 0); + struct device_node *ddc_node __free(device_node) = of_parse_phandle(dev->of_node, "ddc", 0); if (!ddc_node) { DRM_ERROR("Failed to find ddc node in device tree\n"); return -ENODEV; } vc4_hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node); - of_node_put(ddc_node); if (!vc4_hdmi->ddc) { DRM_DEBUG("Failed to get ddc i2c adapter by node\n"); return -EPROBE_DEFER;drivers/gpu/drm/vc4/vc4_hvs.c +0
-1@@ -845,15 +845,13 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) if (vc4->is_vc5) { struct rpi_firmware *firmware; - struct device_node *node;drivers/gpu/drm/vc4/vc4_hvs.c static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) · line 855
Quoted 10 lines
drivers/gpu/drm/vc4/vc4_hvs.c +1
-1+ struct device_node *node __free(device_node) = rpi_firmware_find_node(); unsigned int max_rate; - node = rpi_firmware_find_node(); if (!node) return -EINVAL; firmware = rpi_firmware_get(node); - of_node_put(node); if (!firmware) return -EPROBE_DEFER;Hi,
This patch is marked as new/archived on patchwork[1], however it didn't receive any feedback, and a similar patch has been already merged [2].
Quoted 7 lines
Hello,
Could anyone kindly provide some feedback on this patch?
Thank you
Amer
Hello all,
I have come to realize that unsubscribing from the mailing list shortly after sending this patch prevented me from receiving any feedback. My apologies for this oversight.
Thank you
Amer